Open RocketFlash opened 5 years ago
we need some answers to this question!
Yes, the images without objects are still important for training the model.
Oh! Indeed. I am looking for an answer to this too!
Did anyone figure this? for images without annotations, should we give them an annotation id and leave all fields empty (see below) or just stop incrementing the annotation ids if there is no annotation?: { "info": { }, "licenses": [{ }], "categories": [{ }], "images": [ { "id": 1, "file_name": "1.png", "width": 640, "height": 640, "date_captured": "2020-11-23 20:27:52.616640", "license": 1, "coco_url": "", "flickr_url": "" }, { "id": 30, "file_name": "9.png", "width": 640, "height": 640, "date_captured": "2020-11-23 20:27:52.616640", "license": 1, "coco_url": "", "flickr_url": "" } ], "annotations": [ { "id": 1, "image_id": 1, "category_id": 1, "iscrowd": 0, "area": 113, "bbox": [ 582.0, 352.0, 11.0, 15.0 ], "segmentation": [[ 592.0, ......]], "width": 640, "height": 640 }, { "id": 2, "image_id": 30, "category_id": , "iscrowd": 0, "area": 0, "bbox": [ ], "segmentation": [[ ]], "width": 640, "height": 640 },
Ok, so I found there are two workable solutions to this. 1) Include the image with no annotations in the .json, but just have no annotations associated with that image_id. Then when you are loading the list of annotations for that image it will simply be empty. So check the length of the annotations list, and if it is 0 generate an empty mask for that image's segmentation. 2) Keep the images with no annotations in a separate directory. After you load the images with annotations (using the .json), load the images with no annotations, generating empty masks for their segmentations. Then you can use both of them for training your model. I ended up using a combination of the two because some images looked like they would have segmentations but did not. So the .json did have images with no segmentations. Other images were obviously empty, so I filtered them out before doing segmentation.
Some of the images in COCO dataset do not have objects. Examples of such images are those with image ids 1111, 254124, 465057 etc. You can check it here by entering image id in the search box.
The issue #76 is also helpful.
By checking the annotations in instances_train2017.json or instances_val2017.json for these images without objects, you can see that the corresponding annotations are completely empty. For example, although there is an element in 'images' with 'id' : 1111, there are no elements in 'annotations' with 'image_id' : 1111. We need no information at all in 'annotations' for images without objects.
These images are important to minimize FP. Just ignore this images when calculating the losses for you task (detection, segmentation, ...). You could also penalize the model for detecting something in these images
for some reason my model performance got worse when training with empty images without labels
I created my own COCO styled dataset and some of images have no objects on them. I put images description in images, but I don't know what to do with such images in annotations. Do I need to annotate somehow images without objects? I mean all the pixels are background