weiliu89 / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
4.77k stars 1.67k forks source link

Training on Background-Only data #348

Open azrael417 opened 7 years ago

azrael417 commented 7 years ago

Hello, I am training on a dataset which contains images with no bounding boxes at all, so background only. The bg label is 4 and I told the box layer that. I also specified max negative mining so it should compute the confidence. However, the loss output is zero for these guys. Looking into the box layer, it seems that numneg turns out to be zero (because nummatch definitely has to be zero). My annotation XML for the BG only guys looks like:

<annotation>
  <segmented>0</segmented>
  <folder>data/train</folder>
  <filename>img_00008.png</filename>
  <size>
    <width>800</width>
    <height>600</height>
    <depth>3</depth>
  </size>
  <object>
    <name>background</name>
    <pose>Unpsecified</pose>
    <truncated>0</truncated>
    <difficult>0</difficult>
  </object>
</annotation>

Is that correct? Or does this file need to look differently? What is the right way of including such guys without triggering the loss=0? I also looked into the VOC dataset but skimming through it with grep did not show any background-only files.

weiliu89 commented 7 years ago

You could modify the MineHardNegatives function to change the behavior to include background when there are no ground truth in an image.