potterhsu / easy-faster-rcnn.pytorch

An easy implementation of Faster R-CNN (https://arxiv.org/pdf/1506.01497.pdf) in PyTorch.
MIT License
165 stars 57 forks source link

Support for Training Negative Samples #20

Open mmaaz60 opened 4 years ago

mmaaz60 commented 4 years ago

Hi,

Is this repository allow considering negative images as well for training? For example, while training a cat detector, one may have some images containing cats (+ve images) and some images do not containing cats (-ve images). I noticed that the training script only considers the positive images for training and discard others.

What would be the good way to add support for Negative Samples in training in this repository?

Best Regards, Maaz

Aenteas commented 4 years ago

Hi, Negative examples mean you have no label on the image, so none of the categories are present (I am not sure if you just want to add specific categorie(s)). Either way, you can do it by opening the script of your dataset class under dataset folder (for example coco2017_animal.py) and modifying the init function: remove line 90: if len(annotation) > 0: if you want to add negative examples At line 107 annotation.objects the code is monitoring for specific categories so you can add arbitrary classes there. Hope this helps