AlexeyAB / darknet

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

Incremental Training of yolo v3 #1332

Open worldmovers opened 6 years ago

worldmovers commented 6 years ago

@AlexeyAB If i train my yolov3 on k classes and get the weights generated. Now, if I want to add one more class to it .How to do it

Approach 1 :- Do I need to make k+1 classes in my cfg and then train yolo with all the training dataset [(k class) + 1 new class )]

Approach 2 :- Can i train it on k+1 classes just by using weights of k classes, and images of the k+1 th class.

Your advice will be very helpful in saving lot of time

AlexeyAB commented 6 years ago

@worldmovers

yashkotadia commented 5 years ago

With respect to the incremental addition of classes, I have some queries regarding the annotation of the images of the class to be added.

I have 800 annotated images containing objects of the new class to be added. Now, these images also contain objects from other class as well. However, the annotations I have are only for the new class.

My question is, can I use these annotated images for the incremental training of Yolo or would it end up confusing the model for other classes?

AlexeyAB commented 5 years ago

@yashkotadia

My question is, can I use these annotated images for the incremental training of Yolo or would it end up confusing the model for other classes?

It will end up confusing the model for other classes. You should label all objects.

https://github.com/AlexeyAB/darknet#how-to-improve-object-detection

check that each object are mandatory labeled in your dataset - no one object in your data set should not be without label.

buzdarbalooch commented 5 years ago

hi did anyone solve this issue, actually i have manually annotated the dataset for one class and yolo is detecting that particular object. But i want the system now to detect common classes like(car, person).Without going through the hassel of annotating objects like cars etc.

Sauraus commented 5 years ago

I trained a YOLO v2 model on 142 classes on high res images, when testing on real world data found that my training data was too good, ie. too high fidelity of the images. So I generate a new set of training data where I intentionally degraded the quality by pixelating the objects to be detected.

I am now however seeing NaN for the loss when I loaded up my pre-trained weights file, any ideas on why this would happen?

AlexeyAB commented 5 years ago

@Sauraus

I am now however seeing NaN for the loss when I loaded up my pre-trained weights file, any ideas on why this would happen?

Do you see Nan if you train without pre-trained file? Did you change your cfg-file? Try to check files bad_label.list and bad.list if the exist. Try to check your dataset by using Yolo_mark. And can you show screenshot of Yolo_mark with your new images with pixeled objects?

Sauraus commented 5 years ago

1) If I use the coco weights file then everything is fine, I am getting a regular training run. 2) I changed it for my initial training, but did not change it for the subsequent run with lower quality images.

[net]

Testing

-batch=1 -subdivisions=1 +# batch=1 +# subdivisions=1

Training

-# batch=64 -# subdivisions=8 +batch=64 +subdivisions=8 width=608 height=608 channels=3 @@ -19,8 +19,8 @@ learning_rate=0.001 burn_in=1000 max_batches = 500200 policy=steps -steps=400000,400500 -scales=0.1,0.1 +steps=100,200,500,1000,5000,10000 +scales=2.5,2,1.5,1,0.5,0.1

3) N/A 4) working on this.

daragonor commented 5 years ago

@worldmovers

  • You should change classes= in the cfg-file and data-file.
  • You should train on the dataset [(k classes) + 1 new class )] - i.e. old images + new images
  • You can use pre-trained weights-file for k-classes (but better to train from the begining)

is this like starting from scratch? or does it maintain anything from the previous training?

jemmy1794 commented 4 years ago

It will end up confusing the model for other classes. You should label all objects.

https://github.com/AlexeyAB/darknet#how-to-improve-object-detection

check that each object are mandatory labeled in your dataset - no one object in your data set should not be without label.

@AlexeyAB

SO if i want to train a new class with pre-trained weight, i must have all the classes(new + old) be labeled in my training data set.