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.

Converting Keras-built Yolov3 model (.h5) to IR for inference using NCS1

Maude__Sch
Beginner
1,790 Views

Hello. I have trained my Yolov3 model for object detection using Keras (with tensorflow backend). The trained model is saved using (model.save()) to an h5 file. I can correctly load the model and detect objects. Now, I would like to use this model on my RaspberryPi+Intel Movidius Neural Compute Stick. I have the OpenVINO toolkit installed and running properly on Raspberry pi. 

The process I follow is first transforming my Keras model to Tensorflow model (pb file) using this approach: https://github.com/amir-abdi/keras_to_tensorflow

I can generate the pb file successfully. Then, I follow the OpenVino "Convert YOLOv3 TensorFlow Model to the IR" instructions with the goal of creating the bin and xml files that I can later move to my Raspberry Pi for inference. 

However, I keep getting this error from the model optimizer mo_tf. Do you have any suggestions how I might be able to successfully convert my h5 to bin/xml?

[ ERROR ]  Exception occurred during running replacer "TFYOLOV3" (<class 'extensions.front.YOLO.YoloV3RegionAddon'>): TensorFlow YOLO V3 conversion mechanism was enabled. Entry points "detector/yolo-v3/Reshape, detector/yolo-v3/Reshape_4, detector/yolo-v3/Reshape_8" were provided in the configuration file. Entry points are nodes that feed YOLO Region layers. Node with name detector/yolo-v3/Reshape doesn't exist in the graph. Refer to documentation about converting YOLO models for more information.

 

 

0 Kudos
5 Replies
David_C_Intel
Employee
1,790 Views

Hi Sch,

Thanks for reaching out. Could you please answer the following:

  • Which OpenVINO™  toolkit version are you using?
  • Which OS are you using in the system where you are running the model optimizer?
  • Could you provide us with your frozen model and the model optimizer command you used for us to test on our end?

Best regards,

David

0 Kudos
Maude__Sch
Beginner
1,790 Views

Hello

My openvino version: 2020.2.117

OS: Windows 10

Programs used for training the yolov3 model are from this git repository: https://github.com/AntonMu/TrainYourOwnYOLO

Link to download the original h5 model:  https://we.tl/t-k8XJP04R4D

Link to download the pb model:   https://we.tl/t-pPMMQTDNvk

Link to download the modified json file (I have only one class):  https://we.tl/t-xB4y2mGyAp

The command used for IR conversion from inside the model_optimizer folder (below <path> is replaced with absolute path to the pb model on my computer)

python mo_tf.py --input_model <path>/yolo3model.pb --tensorflow_use_custom_operations_config extensions/front/tf/yolo_v3.json 

Many thanks for your help

0 Kudos
David_C_Intel
Employee
1,790 Views

Hi Sch,

Thank you for the files provided. It seems that this yolov3 model looks different to the supported implementation of yolov3. Also, you are missing the --input_shape parameter, try using the following command and tell us if the issue persists:

python3 mo_tf.py --input_model yolo_v3.pb --input_shape [1,416,416,3]

Regards,

David

0 Kudos
Maude__Sch
Beginner
1,790 Views

Hello David,

 I had tried with input_shape flag as well and it gave the same error. I assume the entry nodes are not the same as the ones model optimizer expect. the model is so large (its pbtxt) that I cannot open the text file and figure out these nodes myself either. 

 I think I am giving up on this issue. Instead, I tried a SSD detection model with Tensorflow object detection API which is supposedly more straightforward and standard to convert to IR. The conversion works with no errors, but I can't make any inference with the converted model. I made a new post about this new issue and would be grateful if you could please take a look at it.

Link to the new issue: https://software.intel.com/node/856984

0 Kudos
David_C_Intel
Employee
1,790 Views

Hello Sch,

The latest OpenVINO™ toolkit version (2020.3) is available if you would like to test with it, we used the command given and the model converted successfully using 2020.2 and 2020.3 versions.

Also, we could not find the equivalent entry points in your frozen model file. To check the nodes in your frozen model, you can use a model viewer tool, for example Netron, and visualize the model you created.

Let us know if you have additional questions.

 

Best regards,

David

0 Kudos
Reply