-
Notifications
You must be signed in to change notification settings - Fork 8k
Converting Yolo v3 models to TensorFlow and OpenVINO(IR) models
To use Yolo v3 model on OpenVINO framework, you should do 2 steps:
- Convert
yolov3.cfg/yolov3.weights
to TensorFlow modelfrozen_darknet_yolov3_model.pb
- Convert
frozen_darknet_yolov3_model.pb
to OpenVINO modelfrozen_darknet_yolov3_model.xml
/.bin
/.mapping
-
Download this repository: https://github.com/mystic123/tensorflow-yolo-v3/archive/ed60b9087b04e1d9ca40f8a9d8455d5c30c7c0d3.zip
-
un-pack it:
sudo apt-get install unzip
unzip file.zip -d tensorflow-yolo-v3
cd tensorflow-yolo-v3
-
Download default Yolo v3 model: https://pjreddie.com/media/files/yolov3.weights
-
Download
coco.names
file: https://raw.githubusercontent.com/AlexeyAB/darknet/master/data/coco.names -
run this command
python3 convert_weights_pb.py --class_names coco.names --data_format NHWC --weights_file yolov3.weights
-
you will get TensorFlow model
frozen_darknet_yolov3_model.pb
After converting the Darknet Yolo v3 model to the TensorFlow model, you can convert it to the Openvino model.
-
Install OpenVINO: https://software.intel.com/en-us/openvino-toolkit/choose-download
-
Put these files to the one directory:
-
frozen_darknet_yolov3_model.pb
- TensorFlow model that you got in previous stage <OPENVINO_INSTALL_DIR>/deployment_tools/model_optimizer/extensions/front/tf/yolo_v3.json
<OPENVINO_INSTALL_DIR>/deployment_tools/model_optimizer/mo_tf.python
-
-
Run the command:
python3 mo_tf.py -b 1 --input_model ./frozen_darknet_yolov3_model.pb --tensorflow_use_custom_operations_config ./yolo_v3.json --data_type FP16
-
You will get OpenVINO model that can be run on CPU, GPU, VPU (MyriadX), FPGA:
-
frozen_darknet_yolov3_model.xml
- model structure -
frozen_darknet_yolov3_model.bin
- model weights -
frozen_darknet_yolov3_model.mapping
- mapping file
-
-
Build C++ examples - run:
<OPENVINO_INSTALL_DIR>/inference_engine/samples/build_samples.sh
-
cd /user/home/inference_engine_samples_build/intel64/Release
-
on CPU:
./object_detection_demo_yolov3_async -i ./test.mp4 -m ./frozen_darknet_yolov3_model.xml -d CPU
-
on VPU:
./object_detection_demo_yolov3_async -i ./test.mp4 -m ./frozen_darknet_yolov3_model.xml -d MYRIAD
-
-
By using Python code:
-
go to
<OPENVINO_INSTALL_DIR>/inference_engine/samples/python_samples
-
python3 object_detection_demo_yolov3_async.py -i test.mp4 -m ./frozen_darknet_yolov3_model.xml -d CPU
-