zhenghao977 / FCOS-PyTorch-37.2AP

A pure torch implement of FCOS 37.2AP
162 stars 39 forks source link

About voc_dataset.py #1

Closed wulele2 closed 3 years ago

wulele2 commented 3 years ago

Hi, If an image has no objects, the corresponding tag file is empty .In the preprocess_img_boxes function, boxes=array([]). In the later collect_fn function, an error is reported. Because it's an empty array. How to modify this bug? Or how to tag background images, including classes and boxes. I look forward to hearing from you soon.

zhenghao977 commented 3 years ago

@wulele2 Thank you for this bug, In voc dataset I didn't meet this problem and ignored it, you can in init remove the no objects' img_id by judging the correspond xml. I will fix this bug soon.

wulele2 commented 3 years ago

Thanks for your reply! Half of my tasks now include only background images, and I don't know what to do with them. According to voc_dataset. Py, just read in the picture, the tag is empty. Could you give me some advice? Thank you very much.

wulele2 commented 3 years ago

I tried tagging images that only included backgrounds: classes=[0],boxes=[0,0,0,0]. Do you think that would work?

zhenghao977 commented 3 years ago

@wulele2 if you would like to train these images with no objects, I think you can use this and in the loss func, for every image in a loop, remove the class id = 0, if the gt num is 0, you can only compute it's focal loss. You can refer to https://github.com/yhenon/pytorch-retinanet/blob/master/retinanet/losses.py .

wulele2 commented 3 years ago

really appreciate your help!