IDEA-Research / DINO

[ICLR 2023] Official implementation of the paper "DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection"
Apache License 2.0
2.1k stars 230 forks source link

Training with images with no label #181

Closed seojpark91 closed 1 year ago

seojpark91 commented 1 year ago

Dear team, Thanks for your awesome work. I have been experimenting with my custom dataset, and I was wondering whether I can train with some images without boxes/labels. It throws a size mismatch error when concatenating tensors for creating refpoint_embed (in deformable_transformer.py) if an image with no label/ no box is concatenated. The reason for including images without labels/boxes is that there are some objects that can easily be mistaken for an object ( for example, blueberry muffin with chocolate muffin). So I want to give some images with chocolate muffin but without box/label so that the network can learn that. Would that be possible with DINO? If it's possible, how can I modify my target dataset without boxes/labels ?

Thank you!

half-truism commented 1 year ago

38

It should work out of the box with negative example images (those with no labeled bounding boxes in them). I was able to train with a 1:1 negative to positive imagery ratio. There is likely some issue with the imagery data you are using and not the fact that some imagery does not have labels within it.

"When there is no target in the current sample, DINO should have the ability to classify all targets as no obj, so there will be loss_cls that need to be backward. In the code, It can be seen that the authors have done a lot of clever detailings on this kind of samples to prevent this special case from raising errors in distributed mode."