Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNN/TF(EfficientNet): add Fill layer, ONNX: add Split layer default axis + const-propagation #19696

Open
teaglin opened this issue Mar 9, 2021 · 8 comments
Labels
category: dnn (onnx) ONNX suport issues in DNN module category: dnn

Comments

@teaglin
Copy link

teaglin commented Mar 9, 2021

System information (version)
  • OpenCV => 4.5.1
  • Operating System / Platform => Mac OS
  • Compiler => Xcode
Detailed description

Using efficient lite model trained in Keras, then exported through tf crashes upon load using DNN. I've tried several different avenues. tf1 / tf2/ onnx. None seem to work. I've included 2 attempts through tensor flow. Both have different crashes.

Attempt 1.

.1/modules/dnn/src/tensorflow/tf_importer.cpp:591: error: (-2:Unspecified error) Input [batch_normalization_1/cond/ones_like] for node [batch_normalization_1/cond/FusedBatchNorm] not found in function 'getConstBlob'
Empty model can be accessed here.
https://www.dropbox.com/s/jfpisyrqokqxagl/frozen_graph.pb?dl=0

Attempt 2.

/opencv/opencv-4.5.1/modules/dnn/src/dnn.cpp:614: error: (-2:Unspecified error) Can't create layer "model_2/global_max_pooling2d_1/Max" of type "Max" in function 'getLayerInstance'
Empty model can be accessed here.
https://www.dropbox.com/s/rxl1ng4h6gcn0y0/frozen_graph2.pb?dl=0

Attempt 3.

This was done using tf2Onnx. So converting directly from Keras to Onnx.

[ERROR:0] global /opencv/opencv-4.5.1/modules/dnn/src/onnx/onnx_importer.cpp (1878) handleNode DNN/ONNX: ERROR during processing node with 3 inputs and 1 outputs: [Conv]:(model_2/efficientnet-b2/stem_bn/FusedBatchNormV3:0)
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: OpenCV(4.5.1) opencv/opencv-4.5.1/modules/dnn/src/onnx/onnx_importer.cpp:1887: error: (-2:Unspecified error) in function 'handleNode'
> Node [Conv]:(model_2/efficientnet-b2/stem_bn/FusedBatchNormV3:0) parse error: OpenCV(4.5.1) opencv/opencv-4.5.1/modules/dnn/src/layers/convolution_layer.cpp:96: error: (-213:The function/feature is not implemented) Unsupported asymmetric padding in convolution layer in function 'BaseConvolutionLayerImpl'
> 
terminating with uncaught exception of type cv::Exception: OpenCV(4.5.1) opencv/opencv-4.5.1/modules/dnn/src/onnx/onnx_importer.cpp:1887: error: (-2:Unspecified error) in function 'handleNode'
> Node [Conv]:(model_2/efficientnet-b2/stem_bn/FusedBatchNormV3:0) parse error: OpenCV(4.5.1) /opencv/opencv-4.5.1/modules/dnn/src/layers/convolution_layer.cpp:96: error: (-213:The function/feature is not implemented) Unsupported asymmetric padding in convolution layer in function 'BaseConvolutionLayerImpl'
>

Empty model can be accessed here.
https://www.dropbox.com/s/03l9myisk15zfye/model.onnx?dl=0

@asmorkalov asmorkalov changed the title DNN tensor flow model crashes. EfficientNet like model crashes on load (TF, TF2, ONNX) Mar 10, 2021
@teaglin
Copy link
Author

teaglin commented Mar 13, 2021

Any update on this? It's basically a show stopper at the moment and I can't find a workaround.

@alalek
Copy link
Member

alalek commented Jul 16, 2021

Please re-check issue with latest OpenCV code from 3.4 or master branch (which includes #20394 fix)

@teaglin
Copy link
Author

teaglin commented Jul 16, 2021

Thanks, will try this out in next few days.

@asmorkalov
Copy link
Contributor

@teaglin Friendly reminder.

@rogday
Copy link
Member

rogday commented Jul 26, 2021

@teaglin, the ONNX model you provided has 2 inputs, as opposed to TF version which has only one - is this intentional? model_2/batch_normalization_1/FusedBatchNormV3's scale field is another input, which looks strange.

@teaglin
Copy link
Author

teaglin commented Jul 26, 2021

Sorry haven't had a chance to try this out yet. Been swamped, working my way to it. @rogday that must be an issue with ONNX converter then. The model only has 1 input. A single, 3 - channel image.

@rogday rogday mentioned this issue Jul 27, 2021
6 tasks
@rogday
Copy link
Member

rogday commented Jul 27, 2021

Can you provide your original keras model in .h5 format?

@rogday rogday changed the title EfficientNet like model crashes on load (TF, TF2, ONNX) DNN/TF(EfficientNet): add Max and Fill layers, ONNX: add Split layer default axis + const-propagation Aug 4, 2021
@alalek
Copy link
Member

alalek commented Aug 14, 2021

Please re-check issue with latest OpenCV code from 3.4 or master branch

@rogday rogday changed the title DNN/TF(EfficientNet): add Max and Fill layers, ONNX: add Split layer default axis + const-propagation DNN/TF(EfficientNet): add Fill layer, ONNX: add Split layer default axis + const-propagation Oct 15, 2021
@rogday rogday reopened this Oct 15, 2021
@asmorkalov asmorkalov added the category: dnn (onnx) ONNX suport issues in DNN module label Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: dnn (onnx) ONNX suport issues in DNN module category: dnn
Projects
None yet
Development

No branches or pull requests

4 participants