Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big bug when loading annotations #5

Open
CuarteroAlvaro opened this issue Jun 21, 2023 · 0 comments
Open

Big bug when loading annotations #5

CuarteroAlvaro opened this issue Jun 21, 2023 · 0 comments

Comments

@CuarteroAlvaro
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant