AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.73k stars 7.96k forks source link

'ReadDarknetFromCfgStream' error in opencv dnn module #2484

Open PimwipaV opened 5 years ago

PimwipaV commented 5 years ago

Dear AlexeyAB,

I follow this tutorial to train one additional class using yolov3 tiny. From the original yolov3-tiny.cfg, I only changed

  1. the number of filters in the convolution layers before yolo layers to be filters= #anchors x (5 + #ofclasses)= 3x(5+1)= 18
  2. the number of class in the yolo layers to be 1 as I train only 1 additional class.

When I run the script to build the detector, using the revised .cfg file and the newly generated weights file, I get this error cv2.error: OpenCV(3.4.4) /darknet/opencv/opencv-3.4.4/modules/dnn/src/darknet/darknet_io.cpp:507: error: (-215:Assertion failed) separator_index < line.size() in function 'ReadDarknetFromCfgStream'

I tried looking at the code and have no idea what can I do to solve the issue. I think it must be some value in the config file. I googled around, looked at opencv forum but couldn't find much on this particular error. Please could you shed some light.

Thank you so much!

AlexeyAB commented 5 years ago

@Pimpwhippa Hi,


2. the number of class in the yolo layers to be 1 as I train only 1 additional class.

PimwipaV commented 5 years ago

@AlexeyAB

Thank you for your prompt reply. Really appreciated.

I've attached my cfg file in txt format below. some parameters doesn't have value, or equal sign? I checked and checked but I don't see anywhere. The error comes from this line of code: net = cv2.dnn.readNet(args.weights,args.config) Could it be anything to do with the path of the args.weights and args.config files as well?

Since you asked, I think I train only 1 class. Do I understand it correctly? I thought by using the pre-trained weight it means training 1 additional class.

Actually my goal is to train 1 additional class. Later, I also want to be able to choose let's say 20 classes out of 9000 classes. That's still a long way to go, or is it possible at all?

When I do detector test with my cfg and new weights file, it says predicted in 0.xxxxxx seconds, but it doesn't say the class (yet I guess, my dataset is too small). I tried also with the original yolo9000. The class I want (snake) is on the combine9k.names. However, it never predicts any snake for me, but it did predict elephants. Did it happen to you like that too? How do I make sure it says the class?

yolov3-tiny250219.txt

ps. I like your coaching style, the way you ask people back some (sometimes tricky) questions ;)

AlexeyAB commented 5 years ago

@Pimpwhippa

You should comment # or remove this line Testing in your cfg-file.


OpenCV-dnn module supports only Yolo v2 and Yolo v3, but OpenCV-dnn doesn't support Yolo9000. There are pre-trained weights that can be used with OpenCV-dnn module: https://github.com/AlexeyAB/darknet#pre-trained-models

If you train with one class - then it will detect only this one class.

PimwipaV commented 5 years ago

@AlexeyAB Thank you! just a #..facepalm myself.. and thank you for the weights files. I meant if I want to choose only the 20 classes that I want, how can I do that?