facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
30.03k stars 7.42k forks source link

Panoptic segmentation COCO format #217

Closed arniwesth closed 4 years ago

arniwesth commented 4 years ago

I am trying to generate and load a data set for Panoptic segmentation. The data format follows this example:

https://github.com/cocodataset/panopticapi/blob/master/sample_data/panoptic_examples.json

The "annotations" part of the JSON looks like this:

"annotations": [
        {
            "file_name": "/data/image_0_mask.png",
            "image_id": 1,
            "segments_info": []
        }
    ],

Loading the data set

register_coco_instances("train", {}, "/data/train.json", "/data")
train_dataset_dicts = DatasetCatalog.get("train")

results in

/opt/conda/lib/python3.7/site-packages/pycocotools/coco.py in createIndex(self)
     96             for ann in self.dataset['annotations']:
     97                 imgToAnns[ann['image_id']].append(ann)
---> 98                 anns[ann['id']] = ann
     99 
    100         if 'images' in self.dataset:
KeyError: 'id'

i.e. the key "id" is expected in the "annotations"' part of the JSON file.

I took a look here: https://github.com/facebookresearch/detectron2/tree/master/datasets But this seems to be specifically for training on the COCO dataset - not for custom data sets.

Is there any working Panoptic segmentation examples on custom data sets to use as a base?

dragen1860 commented 4 years ago

@arniwesth hi, Have you solved your probelm? currently I want train Panoptic segmentation on COCO, Can you kindly tell me how to train? Thank you.

arniwesth commented 4 years ago

@dragen1860 No, unfortunately I did not have time to look closer into this problem.

VahagnTKA commented 4 years ago

@dragen1860 Did you manage to train Panoptic Segmentation? The error you get is probably due to the fact that you use register_coco_intsances function instead of the register_coco_panoptic_separated function in the detectron2 datasets module. This unfortunately means that you cannot simply have a single coco-panoptic type of a json file. I hope in the future there will be a better way to do this.