Ask Your Question
0

Can't create layer "leaky_0/LeakyRelu" of type "LeakyRelu" in function 'getLayerInstance'

asked 2019-04-04 05:08:42 -0600

updated 2019-04-04 05:57:59 -0600

berak gravatar image

I have converted a custom yolov3 model from keras .h5 to tensorflow .pb model. Now when load and run the converted model using opencv dnn module during forward pass I get the following error.

detections = cvNet.forward() cv2.error: OpenCV(4.0.0) /io/opencv/modules/dnn/src/dnn.cpp:413: error: (-2:Unspecified error) Can't create layer "leaky_0/LeakyRelu" of type "LeakyRelu" in function 'getLayerInstance'

I have changed opencv versions but it does not change anything.

Also I have tried yolo darknet pre-trained model that has leakyrelu as activation using readNetfromDarknet and there is no error in this case which makes me think it should not be related to leakyRelu specifically but something related to tensorflow support in opencv dnn.

I searched it on google and it returned with zero response. Can anyone tell me what I can do to remove this error ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-04-04 08:52:27 -0600

dkurt gravatar image

Yeah, looks like we need to modify tf_importer.cpp. On the other hand you can try define LeakyRelu layer to ReLU implementation (read more about custom layers here). If it has no negative slope, just add a line CV_DNN_REGISTER_LAYER_CLASS(LeakyRelu, ReLULayer); before reading network.

edit flag offensive delete link more

Comments

Can you please give the code for it. I have not been able to make it work. What exactly to modify in tf_importer. Or the second solution. Would be of great help thanks

ShrutheeshIR gravatar imageShrutheeshIR ( 2019-07-18 23:59:26 -0600 )edit

Feel free to open an issue on GitHub. Please add a model there as well.

dkurt gravatar imagedkurt ( 2019-07-19 23:49:52 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-04-04 05:07:21 -0600

Seen: 1,540 times

Last updated: Apr 04 '19