Article ID: 000088649 Content Type: Troubleshooting Last Reviewed: 05/20/2022

Unable to Convert YOLOv4 Keras* Model to an Intermediate Representation (IR) Format

BUILT IN - ARTICLE INTRO SECOND COMPONENT
Summary

Steps to convert YOLOv4 Keras model to an IR format.

Description
  • Followed instruction in Convert YOLOv4 Model to IR and failed to convert the model into TensorFlow2* format.
  • Received TypeError: buffer is too small for requested array error when converting YOLOv4 darknet to Keras model.
Resolution

Change directory to Model Downloader and download yolo-v4-tf model using downloader.py script:
cd <INSTALL_DIR>/deployment_tools/tools/model_downloader
sudo python3 downloader.py --name=yolo-v4-tf


Rename custom weight file to yolov4.weights and replace to the following directory:
<INSTALL_DIR>/deployment_tools/tools/model_downloader/public/yolo-v4-tf

Rename custom config file to yolov4.cfg and replace to the following directory:
<INSTALL_DIR>/deployment_tools/tools/model_downloader/public/yolo-v4-tf/keras-YOLOv3-model-set/cfg

Change to the following directory and run pre-convert.py script.
cd /opt/intel/openvino_2021/deployment_tools/open_model_zoo/models/public/yolo-v4-tf
sudo python3 pre-convert.py "<INSTALL_DIR>/deployment_tools/tools/model_downloader/public/yolo-v4-tf" "<INSTALL_DIR>/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

Change directory to Model Optimizer and run mo.py script:
cd /opt/intel/openvino_2021/deployment_tools/model_optimizer
sudo python3 mo.py --framework=tf --data_type=FP16 --output_dir=<INSTALL_DIR>/deployment_tools/tools/model_downloader/public/yolo-v4-tf/FP16 --model_name=yolo-v4-tf --input_shape=[1,416,416,3] --input=image_input --scale_values=image_input[255] --reverse_input_channels --saved_model_dir=<INSTALL_DIR>/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

Related Products

This article applies to 2 products