Assertion failed on getMemoryShape()
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 opencv_dnn.py
Traceback (most recent call last):
File "opencv_dnn.py", line 167, in <module>
main()
File "opencv_dnn.py", 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?
@hj3yoo, Am I right that we can reproduce it using
tiny_yolo.cfg
andtiny_yolo_final.weights
. Please try to use OpenCV's object detection sample:python object_detection.py --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