Skip to content

Can't create "Softplus" in function 'getLayerInstance' #19327

@Asher-Ch

Description

@Asher-Ch

I trained a model on pytorch, its activation function is Mish, and then I converted it to onnx, hoping to execute it on c++ through opencv (I'm using 4.5.0).

Then I encountered some errors like:

[ERROR:0] global /home/opencv-4.5.0/modules/dnn/src/onnx/onnx_importer.cpp (1788) handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 1 outputs: [Softplus]:(34)
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.0) /home/opencv-4.5.0/modules/dnn/src/onnx/onnx_importer.cpp:1797: error: (-2:Unspecified error) in function 'handleNode'

Node [Softplus]:(34) parse error: OpenCV(4.5.0) /home/opencv-4.5.0/modules/dnn/src/dnn.cpp:604: error: (-2:Unspecified error) Can't create layer "34" of type "Softplus" in function 'getLayerInstance'

Does this mean that softplus does not currently support it?

I also tried to write softplus as a torch expression,

x * (torch.tanh(torch.relu(x) + torch.log1p(torch.exp(-torch.abs(x)))))

but I got the other error

[ERROR:0] global /home/opencv-4.5.0/modules/dnn/src/onnx/onnx_importer.cpp (1788) handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 1 outputs: [Abs]:(35)
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.0) /home/opencv-4.5.0/modules/dnn/src/onnx/onnx_importer.cpp:1797: error: (-2:Unspecified error) in function 'handleNode'

Node [Abs]:(35) parse error: OpenCV(4.5.0) /home/opencv-4.5.0/modules/dnn/src/dnn.cpp:604: error: (-2:Unspecified error) Can't create layer "35" of type "Abs" in function 'getLayerInstance'

I am not sure whether these torch ops cannot be parsed. (model has been converted to onnx)

Or still need Custom deep learning layers support like this https://docs.opencv.org/master/dc/db1/tutorial_dnn_custom_layers.html

Hope someone can give me some opinions. Thx.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions