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.

Failed to convert yolov4 to TensorFlow

Mostafa-
Employee
1,712 Views

Hello All,

 

I was following the steps to convert yolov4 to IR as the following link, but I got error for;

from keras-yolo4.model import Mish

https://docs.openvino.ai/latest/openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_YOLO_From_Tensorflow.html#convert-yolov4-model-to-ir

 

and after searching in the community I found another steps, so I followed it, but I got another error;

Mostafa_0-1638446737875.png

 

https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/Not-able-to-convert-yolov4-model-to-tensorflow-format/m-p/1330054#M25814

 

The main goal is convert from yolov4 to IR and try to change the input shape to 416x224 instead to 608x608.

for ex;

python3 mo.py --saved_model_dir yolov4 --output_dir models/IRs --input_shape [1,416,224,3] --model_name yolov4

 

BR,

Mostafa

 

0 Kudos
1 Solution
Wan_Intel
Moderator
1,581 Views

Hi Mostafa-,

Thanks for your patience.

 

From your first post, we noticed that your main goal is to convert from yolov4 to IR and try to change the input shape to 416x224 instead of 608x608.

 

We are sorry to tell you that the documentation you referred to is outdated. You may refer to the following steps (workaround) to convert yolov4 to IR:

 

cd /opt/intel/openvino_2021/deployment_tools/tools/model_downloader

 

sudo python3 downloader.py --name=yolo-v4-tf

 

Rename your weight file to yolov4.weights and replace to the following directory:

/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf

 

Rename your config file to yolov4.cfg and replace to the following directory:

/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf/keras-YOLOv3-model-set/cfg

 

cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/models/public/yolo-v4-tf

 

sudo python3 pre-convert.py "/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf" "/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf"

 

yolo-v4.savedmodel will be generated in the following directory:

/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf

 

cd /opt/intel/openvino_2021/deployment_tools/model_optimizer

 

sudo python3 mo.py --framework=tf --data_type=FP16 --output_dir=/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf/FP16 --model_name=yolo-v4-tf --input_shape=[1,416,224,3] --input=image_input --scale_values=image_input[255] --reverse_input_channels --saved_model_dir=/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf/yolo-v4.savedmodel

 

The Intermediate Representation will be generated in the following directory:

/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf/FP16

 

 

Regards,

Wan

 

View solution in original post

6 Replies
IntelSupport
Community Manager
1,683 Views

 

Hi Mostafa,

 

Thanks for reaching out.


I encountered the same error before and the problem can be fixed by running the following command:

pip install --upgrade tensorflow

pip install --upgrade tensorflow-gpu



Regards,

Aznie


0 Kudos
Mostafa-
Employee
1,627 Views

Hi Aznie,

 

I ran the above commands, and I got a different error;

Mostafa_0-1638776659030.png

 

PS: I am using WSL2 as testing environment.

 

Many Thanks,

Mostafa

 

0 Kudos
Wan_Intel
Moderator
1,610 Views

Hi Mostafa-,

Thank you for reaching out to us.


We are investigating this issue and will update you at the earliest.



Regards,

Wan


0 Kudos
Wan_Intel
Moderator
1,582 Views

Hi Mostafa-,

Thanks for your patience.

 

From your first post, we noticed that your main goal is to convert from yolov4 to IR and try to change the input shape to 416x224 instead of 608x608.

 

We are sorry to tell you that the documentation you referred to is outdated. You may refer to the following steps (workaround) to convert yolov4 to IR:

 

cd /opt/intel/openvino_2021/deployment_tools/tools/model_downloader

 

sudo python3 downloader.py --name=yolo-v4-tf

 

Rename your weight file to yolov4.weights and replace to the following directory:

/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf

 

Rename your config file to yolov4.cfg and replace to the following directory:

/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf/keras-YOLOv3-model-set/cfg

 

cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/models/public/yolo-v4-tf

 

sudo python3 pre-convert.py "/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf" "/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf"

 

yolo-v4.savedmodel will be generated in the following directory:

/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf

 

cd /opt/intel/openvino_2021/deployment_tools/model_optimizer

 

sudo python3 mo.py --framework=tf --data_type=FP16 --output_dir=/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf/FP16 --model_name=yolo-v4-tf --input_shape=[1,416,224,3] --input=image_input --scale_values=image_input[255] --reverse_input_channels --saved_model_dir=/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf/yolo-v4.savedmodel

 

The Intermediate Representation will be generated in the following directory:

/opt/intel/openvino_2021/deployment_tools/tools/model_downloader/public/yolo-v4-tf/FP16

 

 

Regards,

Wan

 

Mostafa-
Employee
1,571 Views

thank you so much Wan, I really appreciate your help

it's now converted and reshaped 🤩

Wan_Intel
Moderator
1,555 Views

Hi Mostafa-,

Glad to know that everything is going well.


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,

Wan


0 Kudos
Reply