Skip to content

cardboardcode/onnx_runtime_cpp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

small c++ library to quickly use onnxruntime to deploy deep learning models

TODO

  • Support inference of multi-inputs, multi-outputs
  • Examples for famous models, like yolov3, mask-rcnn. Might consider supporting more if requested
  • Batch-inference

Installation

  • build onnxruntime from source with the following script
    sudo bash ./scripts/install_onnx_runtime.sh

How to build


make all

# build apps
make apps

How to test apps


Image Classification With Squeezenet


# after make apps
./build/examples/TestImageClassification ./data/squeezenet1.1.onnx ./data/images/dog.jpg

the following result can be obtained

264 : Cardigan, Cardigan Welsh corgi : 0.391365
263 : Pembroke, Pembroke Welsh corgi : 0.376214
227 : kelpie : 0.0314975
158 : toy terrier : 0.0223435
230 : Shetland sheepdog, Shetland sheep dog, Shetland : 0.020529

Object Detection With Tiny-Yolov2 trained on VOC dataset (with 20 classes)


  • Download model from onnx model zoo: HERE

  • The shape of the output would be

    OUTPUT_FEATUREMAP_SIZE X OUTPUT_FEATUREMAP_SIZE * NUM_ANCHORS * (NUM_CLASSES + 4 + 1)
    where OUTPUT_FEATUREMAP_SIZE = 13; NUM_ANCHORS = 5; NUM_CLASSES = 20 for the tiny-yolov2 model from onnx model zoo
  • Test tiny-yolov2 inference apps
# after make apps
./build/examples/tiny_yolo_v2 [path/to/tiny_yolov2/onnx/model] ./data/images/dog.jpg
  • Test result

tinyyolov2 test result

Object Instance Segmentation With MaskRCNN trained on MS CoCo Dataset (80 + 1(background) clasess)


  • Download model from onnx model zoo: HERE

  • As also stated in the url above, there are four outputs: boxes(nboxes x 4), labels(nboxes), scores(nboxes), masks(nboxesx1x28x28)

  • Test mask-rcnn inference apps

# after make apps
./build/examples/mask_rcnn [path/to/mask_rcnn/onnx/model] ./data/images/dogs.jpg
  • Test results:

dogs maskrcnn result

indoor maskrcnn result

Bird Detection With Yolov3 trained on inhouse dataset


  • Details about the my personal repo for training this model will be updated later

  • Test results:

bird detection result

About

small c++ library to quickly deploy models using onnxruntime

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 74.1%
  • Python 14.5%
  • CMake 4.1%
  • Dockerfile 3.3%
  • Shell 3.2%
  • Makefile 0.8%