pjreddie / darknet

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

Training with own data #582

Open abeyang00 opened 6 years ago

abeyang00 commented 6 years ago

I have made my own training and testing dataset for yolo v3. But i have few questions. 1) What is the .cpp file that controls the path for labels, imgs, etc... (Need to change to my folders instead of VOC, COCO, etc) 2) If the number of classes changes, should i change the number of filters in yolov3.cfg file accordingly for every conv layer?

ahsan856jalal commented 6 years ago
  1. filters= num/3*(classes+1+4) for each convolution layer before [yolo] layer
abeyang00 commented 6 years ago

what is "num" exactly?

baristahell commented 6 years ago

"num" is the number of anchors you're asking for. It's divided by 3 in YOLOv3 because the network generates 3 sets of "num" anchors.

lynnw123 commented 6 years ago

https://github.com/pjreddie/darknet/issues/580 BTW, did you get better results in YOLO- V3?

abeyang00 commented 6 years ago

Hm, there might be some issues with the sizes of the objects i'm trying to train. I'm trying to train traffic lights and ROI size is about 20x20 (annotated in txt file) Is that too small for volov3 to train?

ahsan856jalal commented 6 years ago

@abeyang00 well it depends on the image dimension, if the width ,height pixel dimensions are <200 then no problem but if your image is full HD then yes , it is too small

hongrui16 commented 6 years ago

How to train (to detect your custom objects):

(to train old Yolo v2 yolov2-voc.cfg, yolov2-tiny-voc.cfg, yolo-voc.cfg, yolo-voc.2.0.cfg, ... click by the link)

Training Yolo v3:

Create file yolo-obj.cfg with the same content as in yolov3.cfg (or copy yolov3.cfg to yolo-obj.cfg) and: change line batch to batch=64 change line subdivisions to subdivisions=8 change line classes=80 to your number of objects in each of 3 [yolo]-layers: https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L610 https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L696 https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L783 change [filters=255] to filters=(classes + 5)x3 in the 3 [convolutional] before each [yolo] layer https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L603 https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L689 https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L776 So if classes=1 then should be filters=18. If classes=2 then write filters=21.

SanoPan0411 commented 6 years ago

Hi,I have a question.Do we need to change the number of filters of the other conv layers except the final one when training ? I just wondering why the number is 32,128,256 or 1024? Thank you all.

hongrui16 commented 6 years ago

If your purpose is not changing the model, but modifying the number of object detection classes, there is no need in making some changes in other layers.

SanoPan0411 commented 6 years ago

@hongrui16 Thank you for your answer,actually my purpose is to compress the model and I am curious about the reason why filters is 32,64..If I change 1024 to 32 ,what will happen ?

hongrui16 commented 6 years ago

@SanoPan0411 If you compress the model, the performance may be influenced, even may not working. You can have a knowledge of convolutional neural network and full connection net layer. Maybe you can understand it easily.

jim-parsons commented 5 years ago

I have a problem which is OOM during training 2012VOC dataset with GTX1070,please help me with it,thks! The training code is keras with yolo v3 and it will crash after about 2/3 training steps

tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[32,416,416,32] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc

bujingdexin commented 5 years ago

@ SanoPan0411 如果压缩模型,性能可能会受到影响,甚至可能无法正常工作。您可以了解卷积神经网络和完整连接网络层 请问你修改过cfg文件用于自己数据集的训练吗

shlomiamitai commented 5 years ago

when training on a single class, class probability becomes redundant since there is already a confidence that there IS an object. did anyone have any experience with this case?

sakthigeek commented 5 years ago

If you are using Yolo for single class detection, is the class probability needed? I think the Object confidence part is itself enough for the model to learn, right? Or will be model's learnability be affected by ignoring the class probabilities and only using the binary object score?

EslamAlaaZaki commented 5 years ago

@hongrui16 is it possible to use the pre-trained model to detect only certain objects? i'm trying to detect traffic participants like ( cars, trunks, pedestrians, traffic signs ,..etc)

adrianosantospb commented 4 years ago

18

I'd like to use the tiny YOLO to one class only. Where do I find information about how configure?

qingqizhangqingqi commented 4 years ago

filters=3*(classes+5)

Ramanujam-RS commented 4 years ago
  1. filters= num/3*(classes+1+4) for each convolution layer before [yolo] layer

As per my understanding its filters = number of bounding boxes per grid * (classes + 1 + 4) After reading your explanation I took some of the config files like yolo tiny where it has 6 anchor boxes and 80 classes still the filter size is 255 which is same as yolov3 which has 80 classes but 9 anchor boaxes. the idea that num = anchor boxes is suggested by https://github.com/pjreddie/darknet/issues/582#issuecomment-377170719

So to summarise the equation is filters = number of bounding boxes per grid * (clasaes + 5)

SUMANA-collab commented 4 years ago

i want to train the yolov3 model but i want to change the darknet layers like size of filters etc,other than yolo layers,what should be the pretrained weight