Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

Recommended method for converting customized yolov3-tiny to OpenVino

Waragai__Katsunori
848 Views

I have problem in converting customized yolov3-tiny model to OpenVino model.

I have custom trained YoloV3-tiny.weights file. And it works on darknet platform.

I have succeeded in converting original both of yolov3.weights and yolov3-tiny.weights using  'smart-video-workshop/object-detection/tensorflow-yolo-v3'

And converted OpenVino model works.

 

However I have not succeeded in converting  custom trained YoloV3-tiny.weights file to OpenVino model.

The number of classes is different from yolov3-tiny.cfg.

I know that I have to use customized json file from  yolo_v3_tiny.json.

Does anybody knows how to convert customized yolov3-tiny model?

I have found some Github repositories converting YoloV3 models, but I could not complete model conversion.

Please let me know

Recommended method for converting customized yolov3-tiny to OpenVino .

 

I am waiting your reply

---


 

$ cat conv_6classes.sh 
#!/bin/sh

export MO_ROOT=/opt/intel/openvino/deployment_tools/model_optimizer
export DARKNET_ROOT=darknet_model
export MODELNAME=yolov3-tiny-grayscale-6classes

python3 convert_weights_pb.py --class_names ${DARKNET_ROOT}/6classes.names --data_format NHWC --weights_file ${DARKNET_ROOT}/yolov3-tiny-grayscale-6classes.weights --tiny --output_graph ${MODELNAME}_model.pb

python3 $MO_ROOT/mo_tf.py --input_model ${MODELNAME}_model.pb --tensorflow_use_custom_operations_config my_yolo_v3_tiny.json --batch 1



WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
If you depend on functionality not listed there, please file an issue.

WARNING:tensorflow:From /home/someone/.venv/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Traceback (most recent call last):
  File "convert_weights_pb.py", line 52, in <module>
    tf.app.run()
  File "/home/someone/.venv/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "convert_weights_pb.py", line 42, in main
    load_ops = load_weights(tf.global_variables(scope='detector'), FLAGS.weights_file)
  File "/media/someone/ExtremeSSD/gx-front-camera/yolov3-tiny-openvino/utils.py", line 115, in load_weights
    (shape[3], shape[2], shape[0], shape[1]))
ValueError: cannot reshape array of size 8160 into shape (33,256,1,1)

This is the first error in converting using 'smart-video-workshop/object-detection/tensorflow-yolo-v3' information.

 

I need your help.

 

Katsunori

 

 

 

 

0 Kudos
3 Replies
Shubha_R_Intel
Employee
848 Views

Dear Waragai, Katsunori,

As long as you haven't changed the structure  of a tiny yolo v3 model, then OpenVino (both Model Optimizer and Inference Engine) should not have any issues.

I assume you have carefully followed the steps outlined in the Model Optimizer Yolo Doc.

If the only thing you did was custom-trained the model, then you should not have errors with Model Optimizer.

If you do still have errors however, this could be a bug.

Please attach your custom-trained tiny yolo v3 pb to this post as a *.zip and I will take a look.

Thanks !

Shubha

 

0 Kudos
Waragai__Katsunori
848 Views

Thank you for your information.

I succeeded in converting gray-scale yolo v3 tiny model.

 

The only modification is 

<     inputs = tf.placeholder(tf.float32, [None, FLAGS.size, FLAGS.size, 3], "inputs")
---
>     inputs = tf.placeholder(tf.float32, [None, FLAGS.size, FLAGS.size, 1], "inputs") # for gray scale

 

in convert_weights_pb.py.

 

Thanks

Katsunori

 

0 Kudos
Shubha_R_Intel
Employee
848 Views

Dear Waragai, Katsunori,

Congratulations ! And thank you kindly for sharing your knowledge with the OpenVino community !

Shubha

 

0 Kudos
Reply