tree: 3c75862e4b539c24251761cf387b8b0041261530 [path history] [tgz]
  1. CMakeLists.txt
  2. image-classification-predict.cc
  3. Makefile
  4. README.md
example/image-classification/predict-cpp/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
  std::string json_file = "model/Inception/Inception-BN-symbol.json";
  std::string param_file = "model/Inception/Inception-BN-0126.params";
  std::string synset_file = "model/Inception/synset.txt";
  std::string nd_file = "model/Inception/mean_224.nd";
  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

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)