Intel® Distribution of OpenVINO™ Toolkit
Community support and discussions about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all things computer vision-related on Intel® platforms.
5841 Discussions

For generating Custom Object Detection IR files

zian123
Novice
400 Views

Hi 

I want to use openVino for one of my personal project. 

My plan is to create a Custom Object Detection Model, for example I will train 10 types of fruits and then My model will scan and give me the detection result. So after my research I came to know that, first I have to train a model with Computer Vision frameworks and convert the model saved file to IR representaion(.XML and .bin file).  So, I have trained a model with Yolov3 and saved a .weight file. But when I tried to convert the saved file to IR to generate .xml and .bin file by seeing the OpenVino Documentation, it didnt work. 

In the documentation, I have found I have to run this code demo.py from https://github.com/mystic123/tensorflow-yolo-v3

then I found this error,

>python3 convert_weights_pb.py --class_names voc.names --data_format NHWC --weights_file latest.weights
Traceback (most recent call last):
  File "convert_weights_pb.py", line 5, in <module>
    import yolo_v3
  File "/deeplearning/tensorflow-yolo-v3/yolo_v3.py", line 6, in <module>
    slim = tf.contrib.slim
AttributeError: module 'tensorflow' has no attribute 'contrib'

 

After searching for the solution, I came to know that, This problem is occurring because of Tensorflow version, as Now My local machine has tensorflow 2 but it needs tensorflow 1 to run that code, but  I couldn't able to install tensorflow 1 because tensorflow 1 does not support the latest python version(3.9), so I have to downgrade my python version too. I tried to do it but got some other errors. So I quit Yolo.

Now I am looking for any pretrained model from any framework and then I am trying to convert it to IR representation. That's why I move to Tensrorflow(faster_rcnn_resnet101_coco) but this is also giving me error. Now I totally don't know what to do. 

I hope I make you understand about my intention and problem, can you please suggest me any model and how can I convert that  model to IR to create the .xml or .bin file. Any YouTube video, any link?? So that I can refer. If I manage to create the .xml and .bin file then I will do the custom training using that framework and the steps to generate IR files for my project. 

Please help me to solve this problem, its kind of urgent for me. I just need to know which pretrained model I can use? From where I can download it and then how can I convert it to IR Representation?

Thanks 

Zian

 

0 Kudos
1 Solution
Syamimi_Intel
Moderator
351 Views

Hi Zian,

Thank you for reaching out. You are missing double code symbol. Please have a try with the following command:

 

python mo_tf.py --input_model "C:/Users/Md. Afique Amin Zian/Desktop/tensorflow-yolo-v3-master/frozen_darknet_yolov3_model.pb" -b 1 --tensorflow_use_custom_operations_config "C:/Program Files (x86)/IntelSWTools/openvino_2021.4.582/deployment_tools/model_optimizer/extensions/front/tf/yolo_v3.json"

 

 

Regards,

Syamimi


View solution in original post

5 Replies
Vladimir_Dudnik
Employee
376 Views

@zian123 does command line example for faster_rcnn_resnet101_coco, provided in different thread work for you?

Conversion command: c:\miniconda3\envs\py3.7-openvino-dev-2021.4\python.exe -m mo --framework=tf --data_type=FP32 --output_dir=c:\Temp\public\faster_rcnn_resnet101_coco\FP32 --model_name=faster_rcnn_resnet101_coco --reverse_input_channels --input_shape=[1,600,1024,3] --input=image_tensor --output=detection_scores,detection_boxes,num_detections --transformations_config=c:\miniconda3\envs\py3.7-openvino-dev-2021.4\lib\site-packages\mo/extensions/front/tf/faster_rcnn_support.json --tensorflow_object_detection_api_pipeline_config=c:\Temp\public\faster_rcnn_resnet101_coco/faster_rcnn_resnet101_coco_2018_01_28/pipeline.config --input_model=c:\Temp\public\faster_rcnn_resnet101_coco/faster_rcnn_resnet101_coco_2018_01_28/frozen_inference_graph.pb
zian123
Novice
358 Views

Hi,

Thanks for the response. I have figured out and solved this error,

>python3 convert_weights_pb.py --class_names voc.names --data_format NHWC --weights_file latest.weights
Traceback (most recent call last):
  File "convert_weights_pb.py", line 5, in <module>
    import yolo_v3
  File "/deeplearning/tensorflow-yolo-v3/yolo_v3.py", line 6, in <module>
    slim = tf.contrib.slim
AttributeError: module 'tensorflow' has no attribute 'contrib'

I downgraded my tensorflow to version 1 and python to version 3.7, then this error was solved.

But after converting the .weight file to .pb file(Tensorflow). While converting frozen model file into IR files using Openvino inference engine.

I have run this command, 

python mo_tf.py --input_model C:/Users/Md. Afique Amin Zian/Desktop/tensorflow-yolo-v3-master/frozen_darknet_yolov3_model.pb -b 1 --tensorflow_use_custom_operations_config C:/Program Files (x86)/IntelSWTools/openvino_2021.4.582/deployment_tools/model_optimizer/extensions/front/tf/yolo_v3.json

But it is showing this error:

[ ERROR ] The value for command line parameter "tensorflow_use_custom_operations_config" must be existing file/directory, but "C:/Program" does not exist.

I have got the command from  https://docs.openvinotoolkit.org/2020.1/_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_...

Is there anything that I am missing, I don't understand what is wrong with "tensorflow_use_custom_operations_config" parameter. Please help me to solve this error. If this error solved, then I will able to generate IR files. 

As I have told earlier, that I am trying to create a custom object detection model, my model has only 3 classes, Do i  need to change this file(yolo_v3.json), as it is for coco dataset which have (80 classes)?

 

Syamimi_Intel
Moderator
352 Views

Hi Zian,

Thank you for reaching out. You are missing double code symbol. Please have a try with the following command:

 

python mo_tf.py --input_model "C:/Users/Md. Afique Amin Zian/Desktop/tensorflow-yolo-v3-master/frozen_darknet_yolov3_model.pb" -b 1 --tensorflow_use_custom_operations_config "C:/Program Files (x86)/IntelSWTools/openvino_2021.4.582/deployment_tools/model_optimizer/extensions/front/tf/yolo_v3.json"

 

 

Regards,

Syamimi


zian123
Novice
338 Views

Thanks Syamimi, 

It's worked, I have successfully managed to generate IR files.

 

Thanks 

Zian

Syamimi_Intel
Moderator
335 Views

Hi Zian,

Great !

This thread will no longer be monitored since this issue has been resolved. If you need any additional information from Intel, please submit a new question.



Regards,

Syamimi


Reply