object_detection_metrics
object_detection_metrics copied to clipboard
Big bug when loading annotations
I found a very big bnug when loading annotations in the coco_decoder.py script. Currently, it iterates over the original json, that is, over the keys "images", "annotations", "categories", etc when in fact what you want is to iterate over the objects inside "annotations". The change would be simply to iterate over the original json but over the key "annotations". As it does not allow me to create PR, I create this issue,.
def load_pred_object_detection_dataset(fp, dataset: PCOCOObjectDetectionDataset, **kwargs) \
-> PCOCOObjectDetectionDataset:
new_dataset = PCOCOObjectDetectionDataset()
new_dataset.info = copy.deepcopy(dataset.info)
new_dataset.licenses = copy.deepcopy(dataset.licenses)
new_dataset.images = copy.deepcopy(dataset.images)
new_dataset.categories = copy.deepcopy(dataset.categories)
# check annotation
coco_obj = json.load(fp, **kwargs)
annotations = []
for obj in coco_obj["annotations"]:
ann = parse_bounding_box(obj)
if new_dataset.get_image(id=ann.image_id) is None:
print('%s: Cannot find image' % ann.image_id)
if new_dataset.get_category(id=ann.category_id) is None:
print('%s: Cannot find category' % ann.category_id)
annotations.append(ann)
new_dataset.annotations = annotations
return new_dataset