pjreddie / darknet

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

Yolo training on VOC data #257

Open tiagojdias opened 7 years ago

tiagojdias commented 7 years ago

Hi,

So i follow the stages stated on the website to train the VOC data with yolo. Even with GPU (Geforce GTX 1070) the training procedure took me about one day. So, i saw a lot of discussion on the about what config to use ... First i tried with the yolo-voc.cfg and then with yolo-voc.2.0.cfg ... although i'm not obtaining any labels for the dog figure (which was supposed since the network contains that class)

For training i've just used the normal command: ./darknet detector train data/voc.data yolo-voc.2.0.cfg darknet19_448.conv.23 and, then, ./darknet detector test cfg/voc.data cfg/yolo-voc.2.0.cfg backup/yolo-voc_final.weights data/dog.jpg not getting any labels.

Can you pls explain me what i'm doing wrong ...

TheMikeyR commented 7 years ago

What is your batch and subdivision size and what settings did you compile darknet with?

Also a day of training is not unusual, I'm using a K40 and usually training for at least 2 days or 30000 iterations on my own custom dataset.

tiagojdias commented 7 years ago

Well, you're right it also depends on your neural network and the amount of data.

Answering to your question, i'm using batch = 64 and subdivision = 8.

Can you explain me why the yolo-cfg as like a training and a test mode? Cuz i think it's not to clear in the website if you need to comment and uncomment for trainning or testing. Also, i tried to comment the testing part for training and it gave an error. That's why i'm using yolo-voc.2.0.cfg.

Thanks for the reply.

TheMikeyR commented 7 years ago

The testing part is what is used when you want to make a detection on already trained weights, e.g. when you have trained the network for a day you can take the weights and use them together with e.g. demo command and input a video. For this batching doesn't work (input multiple images), and therefore you need to have batch=1 and subdivision=1

And when you train you want to have a big batch size since it makes everything goes quicker (since you are using your GPU and load the memory with many images) and it also generalize much better, since it is averaging over several images when training, if you only train with 1 image for every iteration, every image will have a huge impact on the weights throughout the network, by using a batch, a single image will not throw the network in a new direction (e.g. if your dataset is of cars and you have a ton of red cars and one blue car appear, without batching the blue car might throw the network off so it can only detect the blue car or never being able to detect a blue car, but with batching it will generalize better and be able to detect both red and blue cars).

I don't know why you are not able to train your on VOC, did you try to test with pre-trained weights to check for any errors? https://pjreddie.com/media/files/tiny-yolo-voc.weights

tiagojdias commented 7 years ago

Yes, thank you for the explanation it was pretty clear what you said.

Yeah, i made all the tests it detecting for normal yolo, tiny yolo and even with the input weights darknet19_448.conv.23 ... it was able to detect just a lot of stuff as it was supposed.

But, looking at your asnwer i think i need to modify the yolo-voc.2.0.cfg for testing, am i right?

TheMikeyR commented 7 years ago

Yea in the yolo-voc.2.0.cfg you need to change

[net]
batch=64
subdivisions=8

to

[net]
batch=1
subdivisions=1

for testing and if you want to train you should revert it back.

iraadit commented 7 years ago

Should we use yolo-voc.cfg or yolo-voc.2.0.cfg?

On the website, for YOLOv2, it still links to yolo-voc.cfg

Is yolo-voc.cfg config file corresponding to the YOLOv2 / YOLO9000 paper? And yolo-voc.2.0.cfg to an updated (and better?) config?

tiagojdias commented 7 years ago

In my opinion i think we need to change the yolo-voc.cfg (yolo) batch and subdivision for training...however i'm getting a cuda memory error.

Regarding the Yolov2 (yolo-voc.2.0.cfg) i was able to train the network but was not able to detect on the dog.jpg and person.jpg.

Still not using the 9k version...

Just wanted to train the VOC dataset to learn more about this yolo framework, which i want to use for further research.

2017-10-19 16:51 GMT+01:00 Renaud Bouckenooghe notifications@github.com:

Should we use yolo-voc.cfg or yolo-voc.2.0.cfg?

On the website, for YOLOv2, it still links to yolo-voc.cfg

Is yolo-voc.cfg config file corresponding to the YOLOv2 / YOLO9000 paper? And yolo-voc.2.0.cfg to an updated (and better?) config?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/pjreddie/darknet/issues/257#issuecomment-337951864, or mute the thread https://github.com/notifications/unsubscribe-auth/AMGFRixMnza3Z6GfaawRY85HTes9NUrkks5st3ASgaJpZM4P_BbB .

TheMikeyR commented 7 years ago

@iraadit He created a cfg/yolov1/ containing all the older configs used for yolov1, I believe all the configs which can be used in yolov2 is out in the cfg/ folder and you just pick what you like, I had great success with training using just yolo.cfg and tiny-yolo.cfg where I did small modification such as last layers filter and amount of classes to fit my custom dataset.

@tiagojdias Regarding cuda memory error you need to either increase subdivision (so you load images in smaller subbatches) or reduce the batches (so you are working on smaller amount of images, which result in smaller subbatches)

iraadit commented 7 years ago

@TheMikeyR Here is the answer by AlexeyAB

@iraadit yolo-voc.cfg slightly better than yolo-voc.2.0.cfg, but some people have problems with training yolo-voc.cfg.

Yolo v2: yolo.2.0.cfg and yolo-voc.2.0.cfg - (since 17 Nov 2016): https://arxiv.org/pdf/1612.08242.pdf Yolo v2.x: yolo.cfg and yolo-voc.cfg - (since 10 Apr 2017): https://pjreddie.com/darknet/yolo/

https://github.com/AlexeyAB/darknet/issues/235#issuecomment-338380948

tiagojdias commented 7 years ago

Thank you very much.

I was able to train sucessfully just changing yolo-voc.2.0.cfg batches to 32.

Really appreacited for the help provided guys ;)

TheMikeyR commented 7 years ago

@iraadit great answer from AlexeyAB, thanks 👍

shanghai-Jerry commented 6 years ago

@TheMikeyR when i want to train the network, it stops and dont go on. Am i missing something? and where should i put the training labels?

TheMikeyR commented 6 years ago

https://pjreddie.com/darknet/yolo/ just follow from section Training YOLO on VOC and you should be good to go.

wenbowen123 commented 6 years ago

@TheMikeyR When you say train your custom data, did you train from the provided weights or train from scratch?

Ankit09 commented 6 years ago

Hello @TheMikeyR In darknet yolo object detection method, I can see 80 labels (Objects) of detection. I want my code to detect some specified objects(labels) like a car and the person only. So that the processing time will be less compare to all the object detection. How can I do this?

mkhegazy commented 6 years ago

I have annotated 111 images and set the batch=111 and the subdivision=35 is that ok or, there is a guide I should follow regarding the .cfg configuration . using gtx 1060 and i7-6700HQ

ujsyehao commented 6 years ago

@TheMikeyR Hi, I have a problem, The links for YOLOv2 and YOLOv2 544x544 in http://pjreddie.com/darknet/yolo/ points to the same files: yolo-voc.config , yolo-voc.weights, what's the difference? I am confused, Thank you in advance!

vfbsilva commented 6 years ago

Where are tiny-yolo-voc.weights and https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolo.cfg ?

TheMikeyR commented 6 years ago

@vfbsilva weights here and cfg here

vbcpascal commented 5 years ago

Hello, i'm just starting to learn deep learning. I would like to know whether batch size can be >1 when testing?