Assertion failed on getMemoryShape()

asked 2018-09-14 11:48:02 -0500

hj3yoo gravatar image

updated 2018-09-14 11:49:53 -0500

berak gravatar image

I'm using a tutorial code from here to try out the OpenCV implementation of dnn for YOLOv3. I've made a few notable modification to the code:

# Load names of classes
classesFile = "darknet/data/obj.names";

# Give the configuration and weight files for the model and load the network using them.
#modelConfiguration = "darknet/cfg/tiny_yolo.cfg";
#modelWeights = "darknet/weights/second_general/tiny_yolo_final.weights";
modelConfiguration = "darknet/cfg/yolov3-custom.cfg";
modelWeights = "darknet/backup/third_general_sub_64/yolov3-custom_23000.weights";

First pair is the config and weights for my tiny YOLO model, and the latter is for full YOLOv3 model - they are both trained for the same single-class classification.

Here are the files:

(weight for yolov3-custom is available upon request)

cfg files are used to train their respective weights using darknet repo.

When I run the script for full YOLOv3, it works fine. This also applies to the non-custom model with yolov3.weights from COCO dataset.

However, when I run the script for tiny YOLO, I get the following error:

edmond@edmond-OptiPlex-3020:~/Desktop/MTGCardDetector$ python
Traceback (most recent call last):
  File "", line 167, in <module>
  File "", line 146, in main
    outs = net.forward(getOutputsNames(net))
cv2.error: OpenCV(3.4.2) /io/opencv/modules/dnn/src/layers/region_layer.cpp:93: error: (-215:Assertion failed) inputs[0][3] == (1 + coords + classes)*anchors in function 'getMemoryShapes'

For someone with little C++ knowledge, it's hard to dive down on what went wrong looking at the openCV repo. Can someone please direct me on what to look for?

edit retag flag offensive close merge delete


@hj3yoo, Am I right that we can reproduce it using tiny_yolo.cfg and tiny_yolo_final.weights. Please try to use OpenCV's object detection sample: python --model tiny_yolo_final.weights --config tiny_yolo.cfg --width 416 --height 416 --scale 0.00392 --rgb --input example.jpg. Please also test the latest state of 3.4 or master branch

dkurt gravatar imagedkurt ( 2018-09-17 01:53:08 -0500 )edit