Skip to content

ONNXImporter ERROR while import YOLO 4 with asymetric padding (TensorFlow 2.x & Keras) #19316

@cpraschl

Description

@cpraschl
System information (version)
  • OpenCV => 4.5.1.48
  • Operating System / Platform => Windows 64 bit / Python
Detailed description

I have created a YoloV4 Keras Model using TensorFlow-2.x-YOLOv4, that I am converting to ONNX using keras2onnx, which works fine. For this I am using the following code:

from keras.backend import common as K

model = Load_Yolo_model() # TensorFlow-2.x-YOLOv4 specific code

K.set_image_data_format('channels_first') # change format for OpenCV
onnx_model = keras2onnx.convert_keras(model, model.name)
keras2onnx.save_model(onnx_model, "model.onnx")

When I am loading the model using OpenCV's net = cv2.dnn.readNetFromONNX('model.onnx') I am getting the following Exception:

cv::dnn::dnn4_v20201117::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 3 inputs and 1 outputs: [Conv]:(convolution_output19) 
Steps to reproduce

I have attached the onnx.model here:
model.zip

If you open it using the following code the mentioned exception is raised:

from cv2 import cv2
net = cv2.dnn.readNetFromONNX('model.onnx')
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    answers.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions