pjreddie / darknet

Convolutional Neural Networks
http://pjreddie.com/darknet/
Other
25.69k stars 21.33k forks source link

Is it possible to simplify the sets to speed things up if I only care about one specific object? #142

Open downhiller opened 7 years ago

downhiller commented 7 years ago

Yolo works straight out of the box perfectly for my needs, and identifies correctly the object in the photos that I've tested it with. I only want to test for one specific object though, I don't care if there's chairs or sheep or cars or trees in the photo as well. It should be possible to tell darknet when running it to look for one specific object.

Maybe it is and I'm being blind/stupid?

Thank you!

MithileshHinge commented 7 years ago

Why not train it yourself for the particular classes that you want it to detect?

downhiller commented 7 years ago

I assume that "training" it means get (say) 1000 images, and tell the code the bounding box of any occurrences of my desired objects in each image?

If so that seems like a large undertaking when yolo appears to already dectect my objects perfectly - all I want to do is to STOP it from looking for the other thousands of objects that yolo contains?

wanghua609 commented 7 years ago

I have met the same question. I only want to detect the person and car. How to realize this?

MithileshHinge commented 7 years ago

In yolo-voc.cfg file, classes = 2 In voc.data file, classes = 2 In voc.names file, delete all the lines except "person" and "car"

Then follow this to train on voc dataset: Follow this: https://pjreddie.com/darknet/yolo/#train-voc (You don't need to create your own dataset of, like you said, 1000 images)

downhiller commented 7 years ago

Thanks!

I get as far as

./darknet detector train cfg/voc.data cfg/yolo-voc.cfg darknet19_448.conv.23

and this happens:

"darknet: ./src/parser.c:280: parse_region: Assertion `l.outputs == params.inputs' failed."

Any idea why?

downhiller commented 7 years ago

Fixed it. You need to find the "filters" line above the classes line in yolo-voc.cfg and change the number to (classes + 5) * 5

So for 2 classes, filters becomes 35, 3 classes it becomes 40, etc.

Solution from this link: https://groups.google.com/forum/#!topic/darknet/B4rSpOo84yg

MithileshHinge commented 7 years ago

More specifically: (classes + coords + 1)*NUM. Please close this issue if solved.

downhiller commented 7 years ago

Final question: how many images is this going through when I train it? It tells me how many it's done, but not how many more there are to go. I'm guessing that it being on 30 images after 15 minutes is pretty bad news though, but that's my fault for trying to run it on a dedicated centos server. Maybe I'd get better luck running it on my home PC with GPU and then copying across?

MithileshHinge commented 7 years ago

Sorry, I don't know that. It might take as much as a week to train the net.

AlexeyAB commented 7 years ago

@downhiller Usually sufficient 2000 iterations for each class(object). But for a more precise definition when you should stop training, use the following manual: https://github.com/AlexeyAB/darknet#when-should-i-stop-training

xzhub commented 6 years ago

@AlexeyAB Without other competing classes, will YOLO tend to make false positive result? Say, if you only want to detect Motorbike and Person, so you train YOLO with only these two classes -- Will your new YOLO model report a Bike as Motorbike more often than the original YOLO VOC model??

AlexeyAB commented 6 years ago

@xzhub If you use fewer classes, but use the same good and huge dataset - then there will be:

downhiller commented 6 years ago

As an aside, roughly how fast should this object detection be able to work on a 1024px JPEG on a 6-core Xeon CentOS dedicated server (no useful GPU etc?)

At the moment it's taking something like 20 seconds per photo, which isn't very useful - but it's probably something I'm doing wrong - or the lack of GPU!

AlexeyAB commented 6 years ago

@downhiller To use on CPU-only systems try to use:


There were added Yolo v2/v3 inside the OpenCV - these implementation are the fastest for CPU

fiorano10 commented 5 years ago

If I were to train a model on just 1 or 2 classes using the voc dataset as asked by the OP, would the inference be faster? If yes, how much?

gao-lex commented 5 years ago

yes,yolo will faster than before.

i test it on my own dataset and object.

Miketurner681 commented 5 years ago

could you not just use tiny yolo?

josephdereje commented 5 years ago

the detection accuracy will be low when u use tiny yolo

Thibdib commented 5 years ago

I still get the error "darknet: ./src/parser.c:315: parse_yolo: Assertion `l.outputs == params.inputs' failed. Abandon (core dumped)" I have made the modification on yolov3-voc, voc.names and voc.data. Here are the pictures.

yolov3-voc

In the yolov3-voc.cfg, I have set classes = 1 and filters = ( 1 +5 ) * 5 = 30 filters_classes

And in voc.data file: voc_data

Can you help me pls ?

ohnu93 commented 4 years ago

In yolo-voc.cfg file, classes = 2 In voc.data file, classes = 2 In voc.names file, delete all the lines except "person" and "car"

Then follow this to train on voc dataset: Follow this: https://pjreddie.com/darknet/yolo/#train-voc (You don't need to create your own dataset of, like you said, 1000 images)

I've been trying to follow this guide to change the dataset, but I cannot find voc.data file anywhere in the directory. What can I do...?

biketrooper commented 4 years ago

In yolo-voc.cfg file, classes = 2 In voc.data file, classes = 2 In voc.names file, delete all the lines except "person" and "car" Then follow this to train on voc dataset: Follow this: https://pjreddie.com/darknet/yolo/#train-voc (You don't need to create your own dataset of, like you said, 1000 images)

I've been trying to follow this guide to change the dataset, but I cannot find voc.data file anywhere in the directory. What can I do...?

Same here... :-/

fiorano10 commented 4 years ago

classes= 20 train = <path-to-voc>/train.txt valid = <path-to-voc>2007_test.txt names = data/voc.names backup = backup Here you go, @biketrooper @ohnu93