laclouis5 / globox

A package to read and convert object detection datasets (COCO, YOLO, PascalVOC, LabelMe, CVAT, OpenImage, ...) and evaluate them with COCO and PascalVOC metrics.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: unsupported operand type(s) for +: 'AnnotationSet' and 'AnnotationSet'

ruckc opened this issue · comments

Describe the bug
When trying to combine multiple AnnotationSet objects, get unsupported operand type '+'.

To Reproduce
Steps to reproduce the behavior:

coco1 = AnnotationSet.from_coco("coco-1/annotations/instances_default.json")
coco2 = AnnotationSet.from_coco("coco-2/annotations/instances_default.json")
coco = coco1+coco2

Expected behavior
Per the documentation, I expected the ability of combining AnnotationSet objects.

Environment (please complete the following information):

  • Ubuntu 22.04
  • Python 3.10.6
  • Globox 2.1.0

Additional context
I believe we need to add an __add__ method to support AnnotationSet concatenation.

Hi,

This is a documentation error, I modified this operator from + to | a while ago because it matches more closely the semantics: its a union (in the mathematical sense) rather than a concatenation. The | operator is used for Python dictionaries and set so I believe this API is cleaner since AnnotationSet behaves like a set as its name suggests.

Could you try that | works for you, i.e. coco = coco1 | coco2? I'll update the wrong documentation, thanks for the report.

Yes, that works. Now I just need to figure out how to programmatically deal with duplicate IDs that are unique images.

It depends how you define "unique" images. Normally an image identity is defined by its id so you should not have two ID's for the same image/annotation. You could post-process the result of the union and remove duplicate images.