VGG16
VGG16 is one of the DNN models for image classification. The original paper of this network is: Very Deep Convolutional Networks for Large-Scale Image Recognition.
Usage
This gist implements an VGG16 service in Owl, and provides simple interfaces to use. Here is an example:
#zoo "f5409c44d6444921a8ceec00e33c42c4"
let img = "/path/to/your/image.png";;
let labels = Vgg16.infer img;;
let labels_json = Vgg16.to_json ~top:5 labels;;
let labels_tuples = Vgg16.to_tuples labels;;
Note that you need to download the weight file "vgg16_owl.network" from here to current directory before running the code.
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.
Prerequisite
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