Squeezenet is one of the recent models to do image recognition, with focus on model size reduction. It can achieve AlexNet-level accuracy on ImageNet with 50x fewer parameters. The original paper of this network is here.
This gist implements an Squeezenet service in Owl, and provides simple interfaces to use. Here is an example:
#zoo "c424e1d1454d58cfb9b0284ba1925a48"
let img = "/path/to/your/image.png";;
let labels = Squeezenet.infer img;;
let labels_json = Squeezenet.to_json ~top:5 labels;;
let labels_tuples = Squeezenet.to_tuples labels;;
The infer
function takes image path as input. The image chould be of any popular formats: jpeg, png, etc. This gist contains an exemplar image for you to use, but feel free to use your own.
The output of this function is a 1x1000
vector. The user can further get human-readable classification results by passing this vector to_json
or to_tuples
. The output of former function is the top-N inference result as a json string, and the latter's is a list, each element in the form of [class: string; propability: float]
. The probability is in range [0, 1].
The top
parameter specifies how many top-N results are shown. It is default to be 5.
This application relies on the tool ImageMagick
to manipulate image format conversion and resizing. Please make sure it is installed. For example, on Ubuntu or Debian, you can use command:
sudo apt-get install imagemagick