Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Image Classification Example of C++

This is a simple predictor which shows how to use c api for image classfication.

It uses opencv for image reading

How to Use

Build

  1. Edit image-classification-predict.cc file, change the following lines to your model paths:
  // Models path for your model, you have to modify it
  BufferFile json_data("model/Inception/Inception_BN-symbol.json");
  BufferFile param_data("model/Inception/Inception_BN-0039.params");
  1. Edit synset file path if you have it:
  // Synset path for your model, you have to modify it
  std::vector<std::string> synset = LoadSynset("model/Inception/synset.txt");
  1. You may also want to change the image size and channels:
  // Image size and channels
  int width = 224;
  int height = 224;
  int channels = 3;
  1. Simply just use our Makefile to build:
make

Usage

  • Run:
    ./image-classification-predict apple.jpg

The only parameter is the path of the test image.

Tips

  • The model used in the sample can be downloaded here: http://pan.baidu.com/s/1sjXKrqX

  • If you don't run it in the mxnet root path, maybe you will need to copy lib folder here.

Author

Thanks

  • pertusa (for Makefile and image reading check)

  • caprice-j (for reading function)

  • sofiawu (for sample model)

  • piiswrong and tqchen (for useful coding suggestions)