Water Chan
Water Chan

Reputation: 101

cv2.dnn.readNetFromDarknet error: (-212:Parsing error) Unsupported activation: relu in function 'cv::dnn::darknet::ReadDarknetFromCfgStream'

I tried to run the Openpose on darknet with weights and cfg downloaded from this place: https://github.com/lincolnhard/openpose-darknet

This is the error when I tried to create a net in Opencv

modelConfiguration = path to cfg file
modelWeights = path to weights file
darknet = cv2.dnn.readNetFromDarknet(modelConfiguration, modelWeights)

error Traceback (most recent call last) in () ----> 1 darknet = cv2.dnn.readNetFromDarknet(modelConfiguration, modelWeights)

error: OpenCV(4.0.0) C:\projects\opencv-python\opencv\modules\dnn\src\darknet\darknet_io.cpp:552: error: (-212:Parsing error) Unsupported activation: relu in function 'cv::dnn::darknet::ReadDarknetFromCfgStream'

Upvotes: 6

Views: 11513

Answers (2)

0xPrateek
0xPrateek

Reputation: 1188

The fix is either you install the latest master branch of openCV or OpenCV version 3.4.XX.XX Only these branches support yolo4.

You can install another version of OpenCV by the following snippet:

!pip install opencv-contrib-python==3.4.13.47 --force-reinstall

Upvotes: 4

zhicheng duan
zhicheng duan

Reputation: 101

as you konw, opnecv 4.0.0 does not support the relu activation now. I found some project faced the same problem, but he adjusted opencv for darknet, Support CNN "relu" and maxpool "VALID", you can reference it.

https://github.com/chineseocr/opencv-for-darknet

hope it will solve your problem.

Upvotes: 0

Related Questions