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.
6404 Discussions

Darknet Yolov4 object detection .weight and .cfg to IR representation.

KarthickM
Beginner
1,846 Views

Hi,

 

I have been exploring on converting darknet yolov4 .weight file .cfg to tensorflow (.pb) and used mo.py to convert to IR .bin and .XML file.

 

I followed the instructions from here (https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_YOLO_From_Tensorflow.html ) for yolov3 and object detection worked fine however with less accuracy.

 

Now, I tried the procedure mentioned for yolov4 :

  1. Download YOLOv4 weights from yolov4.weights.
  2. Clone the repository with the YOLOv4 model.
    content_copy
    git clone https://github.com/Ma-Dan/keras-yolo4.git       ==========>  did not work. 
    git clone  https://github.com/Runist/YOLOv4/  ==> Used this link to convert to .pb     
  3. Convert the model to the TensorFlow 2* format. Save the code below to the converter.py file in the same folder as you downloaded yolov4.weights and run it.
    content_copy
    from keras-yolo4.model import Mish
     
    model = tf.keras.models.load_model('yolo4_weight.h5', custom_objects={'Mish': Mish})
    tf.saved_model.save(model, 'yolov4')
content_copy
python converter.py
  1. Run Model Optimizer to converter the model from the TensorFlow 2 format to an IR:

NOTE: Before you run the convertion, make sure you have installed all the Model Optimizer dependencies for TensorFlow 2.

content_copy
python mo.py --saved_model_dir yolov4 --output_dir models/IRs --input_shape [1,608,608,3] --model_name yolov4
 
It created yolov4 .bin and .XML files and when I used those files in demo object_detection_demo_yolov3_async application. Firstly, I encountered the problem because 'yoloregion' was not found from the XML. To resolve the issue, I provided classes, anchor, and mask values manually. Later while parsing output yoloregion, I did not see a valid threshold, confidence, and threshold values from the output blob.
 
I used a similar parse-yolo-region function in yolov3 (ParseYOLOV3Output) and as I mentioned above, it did not work.
 
Do I have to use different rendering output object details for yolov4?
 
Thanks & Regards,
Karthick
0 Kudos
2 Replies
IntelSupport
Community Manager
1,800 Views

Hi Karthick,

Thanks for reaching out. Can I know which version of the OpenVINO toolkit you are using? Please share the screenshot of any error or issue that you got.

 

Regards,

Aznie


0 Kudos
IntelSupport
Community Manager
1,710 Views

Hi Karthick,

Thank you for your question. If you need any additional information from Intel, please submit a new question as this thread is no longer being monitored.


Regards,

Aznie


0 Kudos
Reply