AlexeyAB / darknet

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

Can't run darknet detector demo with yolov4-tiny.cfg classes = 1. #6374

Open minertom opened 4 years ago

minertom commented 4 years ago

I have originally, over a year ago, trained with yolov3.cfg with "classes = 1" on the "darknet53.conv.74" weights. Training was done with

"./darknet detector train darknet.data yolov3.cfg (with classes = 1) darknet53.conv.74"

I was able to use the following after training:

"/darknet detector demo darknet.data yolov3.cfg yolov yolov3_last.weights -c 0"

The inference was very good and the fps was acceptable. The darknet.data file uses "classes.names" with one class only, called airplane.

That was on a Linux machine with Ubuntu 18.04 and a gtx 1060 video card., like I said, over a year ago.

However, I just found that the resultant set of weights was "too much" for a Windows 10 machine using a GTX 1650 embedded graphics card. I was getting about 4 fps on the windows 10 machine.

Back on the linux machine now, that I use for development.

I attempted to train a set of tiny weights using yolov4-tiny.cfg and the yolov4-tiny.conv.29 weights as recommended in https://github.com/AlexeyAB/darknet#how-to-train-tiny-yolo-to-detect-your-custom-objects

That did not result in any errors in training but when I attempted to run "./darknet detector demo darknet.data yolov4-tiny.cfg and yolov4-tiny_last.weights -c 0" , I got an error: "Parameters don't match: in cfg-file classes=80, in data-file classes=1"

That makes sense because classes=80 in the cfg file while there is only one class listed in the classes.names file.

So, I attempted to change "classes = 80" to "classes = 1" in the yolov4-tiny.cfg file just as I had done over a year ago in the yolov3.cfg file.

During training I get the error "filters= in the [convolutional]-layer doesn't correspond to classes= or mask= in [yolo]-layer ". That also makes sense but I do not understand why that was not a problem when I originally did that with yolov3.cfg.

The bottom line is that I only have one data class, airplane, and I need to reduce the weights so that a "lesser" graphics card can handle the computational load with a higher fps, even though the inference would be reduced.

Just some final information, the darknet.data file consists of "airplane_train.txt" and "airplane_test.txt" which refer to JPEG images derived from the openimages data set and labeled properly.

Thank You Tom

Szamtu commented 4 years ago

So, I attempted to change "classes = 80" to "classes = 1" in the yolov4-tiny.cfg file just as I had done over a year ago in the yolov3.cfg file.

Did you adjusted filters too?

Aditionaly, you need to adjust classes in data/obj.data or whatever darknet data file you have.

kalikhademi commented 3 years ago

So, I attempted to change "classes = 80" to "classes = 1" in the yolov4-tiny.cfg file just as I had done over a year ago in the yolov3.cfg file.

Did you adjusted filters too?

Aditionaly, you need to adjust classes in data/obj.data or whatever darknet data file you have.

Hi , I have the same problem, too! I changed the classes number in the config file. I would like to know that all the filters in the convolutional layers need to be equal to 18 (5+1*3) or just in some specific layers. I do not see any filters in the YOLO layers.

Thanks for your help!