waspinator / pycococreator

Helper functions to create COCO datasets
Apache License 2.0
765 stars 179 forks source link

Support multiple annotations in the same image of the same class #29

Closed timofurrer closed 2 years ago

timofurrer commented 4 years ago

I'd be very useful to get multiple annotations from a single binary mask whereas disconnected shapes are separate annotations instead of one.

Is that something which could make it into this package?

overclock98 commented 3 years ago

how do I use "pycococreatortools.create_annotation_infos" ? I tried to change "pycococreatortools.create_annotation_info" to "pycococreatortools.create_annotation_infos". but when I tried to load json to coco api I'm getting an error,


loading annotations into memory...
Done (t=0.11s)
creating index...
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-131-b9f9f7b13f18> in <module>()
----> 1 example_coco = COCO(annotation_file)

1 frames
/usr/local/lib/python3.6/dist-packages/pycocotools/coco.py in createIndex(self)
     92         if 'annotations' in self.dataset:
     93             for ann in self.dataset['annotations']:
---> 94                 imgToAnns[ann['image_id']].append(ann)
     95                 anns[ann['id']] = ann
     96 

TypeError: list indices must be integers or slices, not str

this is my notebook https://github.com/overclock98/PSB-2015-crowdsourced-nuclei-dataset-to-coco/blob/master/PSB_2015_crowdsourced_nuclei_dataset_to_coco.ipynb