Skip to content
Branch: master
Find file History
arcadiaphy and eric-haibin-lin fix memory-related issues to enable ASAN tests (#14223)
* fix heap overflow

* fix memory leak of optimizer and executer

* uncomment memory pool free

* run cleanup in engine shutdown phase

* make asan tests blocking

* fix abort in mxnet shutdown, use forked submodules temporally for tests

* trigger CI

* change submodule mshadow

* change submodule dmlc-core
Latest commit 053ffc7 Mar 3, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
CMakeLists.txt [ARM] improvements to ARMv7 based builds. (#11245) Jun 15, 2018
Makefile [MXNET-910] Multithreading inference. (#12456) Sep 19, 2018 fix memory-related issues to enable ASAN tests (#14223) Mar 3, 2019

Image Classification Example Using the C Predict API

This is a simple predictor which shows how to use the MXNet C Predict API for image classification with a pre-trained ImageNet model in a single thread and multiple threads.


How to Use this Example

Download the Model Artifacts

  1. You will need the model artifacts for the Inception ImageNet model. You can download these from
  2. Place them into a model/Inception/ subfolder, or if not, you will need to edit the source file and update the paths in the Build step.


  1. If using a different location for the model artifacts, edit file, and change the following lines to your artifacts' 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:


Run the example by passing it an image that you want to classify. If you don't have one handy, run the following to get one:


Then run the image-classification-predict program, passing the image as the first argument and the number of threads as the second parameter.

./image-classification-predict 1920px-Honeycrisp.jpg 1


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



  • pertusa (for Makefile and image reading check)

  • caprice-j (for reading function)

  • sofiawu (for sample model)

  • piiswrong and tqchen (for useful coding suggestions)

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.