pjreddie / darknet

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

Loss decrease slowly when Train darknet to detect one class from VOC datasets #436

Open patrick-ucr opened 6 years ago

patrick-ucr commented 6 years ago

I am using tiny-yolo to detect only one class from VOC datasets by combining all the 20 classes into one, which I call "object of interest" and ignore whether it's a car or a cat for example.

I set in config file to have classes=1 and filter size of the second last layer = 30. I am using Nvidia Tesla 100 to train, which is impressively fast.

My problem is that the loss value gets fluctuated around 15-25 but I see @wakanawakana can achieve loss down to 10^-3. What do you think I can do to improve it? My conjecture is that performance must be better when I reduce the complexity of the task

"detect an object from one of the 20 classes but do not have to tell me what class it belongs to"

baristahell commented 6 years ago

Have you tried running validation to see if you actually detect something, and how precisely?

I have encountered values of loss up to 50 with my dataset, a raw value doesn't mean much, depending on what you're trying to do, it's mainly how it lowers that matters (if you run the exact same tests you'll get approximatey the same values thought).

patrick-ucr commented 6 years ago

Thank you @baristahell. I will validate it with a separate test set today.

I am not sure whether I did something wrong. Is Yolo a generic model where I can efficiently train my own dataset with whatever number of classes? Or I need to do some engineering on the hidden layers' configuration.

sivagnanamn commented 6 years ago

@patrick-ucr Both versions of YOLO (V1 & V2) suffer from below items:

  1. Object Localization error
  2. Detecting Overlapping objects
  3. Detecting small objects (say less than 16x16)

To avoid 2&3, you may have to increase your test image resolution (ex: 832x832).

Other than the above issues, YOLO is a pretty generic model that can be trained on custom data. Modifying the layers might be necessary if you're not getting a decent performance straight away.

baristahell commented 6 years ago

To train on any set you will just need to modify, in the .cfg :

  1. Compute new k-means for your anchors, so they match the repartition of your data
  2. Change the number of classes and anchors (~number of proposals) in the region layer
  3. Change the last conv layer number of filters to (numberofclasses+5)*numberofanchors Then, you also can add stopbackward=1 to a layer to freeze it, if you want to re-use a good model like one trained on ImageNet and don't want to mess up the first layers weights.

Then, you have to tweak the .data and the .names, but that's a piece of cake.

patrick-ucr commented 6 years ago

@sivagnanamn Thank you. @baristahell I don't change the ground truth data at all, using VOC 2007 and VOC 2012 as instructed in the tutorial on Yolo website. So I don't think I need to change anchors but I can give it a try. However, I don't really know how to find good values and good numbers of them.

Now they are anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52

Again, I reduce the functionality of Yolo (or Tiny-Yolo) to detect an object without having to classify what it is. But even with minimal change in the configuration of Tiny-Yolo, I still see high loss during training.

IvanZheleznyakov commented 5 years ago

@patrick-ucr hi! Have you solved it? I have the same problem, my avg loss is about 50-60 and it isnt decreasing for many iterations on any datasets