问题
I'm trying to switch from using Yolo v2 to Yolo v3 and can't get the detection to work. I'm getting the error
OpenCV Error: Parsing error (Unknown layer type: shortcut) in ReadDarknetFromCfgFile
Anybody know how I can fix this? Using a cfg file from Yolo v2 works fine.
回答1:
Support for running YOLOv3 has been added to OpenCV master branch (3.4.3).
You should be able to use YOLOv3 config and weights with OpenCV DNN module to perform object detection.
net = cv2.dnn.readNet(args.weights, args.config)
blob = cv2.dnn.blobFromImage(image, scale, (416,416), (0,0,0), True, crop=False)
net.setInput(blob)
outs = net.forward(get_output_layers(net))
Full code here.
Have a look at the object detection example in the samples/dnn directory on OpenCV's github repo.
This blog post (written by me) explains in detail about performing object detection with pre-trained YOLOv3 weights on COCO dataset to detect 80 common objects in context.
Hope this helps.
来源:https://stackoverflow.com/questions/49925933/opencv-unknown-layer-type-running-darknet-detect