[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Running TensorFlow object detection model using onnxruntime.

Notifications You must be signed in to change notification settings

asiryan/object-detection-tf

Repository files navigation

Running TF object detection model using onnxruntime

Installation

Install python 3+ dependencies.

tensorflow: 1.12.0
onnx: 1.6.0
tf2onnx: 1.5.5
onnxruntime: 1.1.0

TF to ONNX

Download TF object detection model trained on COCO dataset from the Model Zoo and convert it to onnx model.
For example download ssd_mobilenet_v1_coco_2018_01_28 and convert it to onnx model from saved_model.pb

python -m tf2onnx.convert 
  --opset 11 
  --fold_const 
  --saved-model ssd_mobilenet_v1_coco_2018_01_28/saved_model/ 
  --output ssd_mobilenet_v1_coco_2018_01_28/model.onnx

or from frozen_inference_graph.pb

python -m tf2onnx.convert 
  --opset 11 
  --fold_const 
  --graphdef ssd_mobilenet_v1_coco_2018_01_28/frozen_inference_graph.pb 
  --output ssd_mobilenet_v1_coco_2018_01_28/frozen.onnx 
  --inputs image_tensor:0 
  --outputs detection_boxes:0,detection_classes:0,detection_scores:0,num_detections:0

For run python and C# examples below download path with already-made ssd_mobilenet_v1_coco_2018_01_28 onnx models and move it to repository root folder.

Python script

Run python script object_detection_image_onnx.py to test converted onnx model.

Figure 1. Python example

C# application

Build C# source code and run application.

Figure 2. C# example

References

[1] TensorFlow detection model zoo.
[2] Tutorial: how to convert them to ONNX and run them under onnxruntime.
[3] Microsoft: ONNX Runtime C# API.

Releases

No releases published

Packages

No packages published