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

KeyError: 'iscrowd' #83

Open
Mary14-design opened this issue Apr 2, 2024 · 1 comment
Open

KeyError: 'iscrowd' #83

Mary14-design opened this issue Apr 2, 2024 · 1 comment

Comments

@Mary14-design
Copy link

I am trying to convert instances_train2017.json from https://cocodataset.org/#home and it returns the following error

Traceback (most recent call last): File "/tmp/workspace/codes/JSON2YOLO/general_json2yolo.py", line 393, in <module> convert_coco_json( File "/tmp/workspace/codes/JSON2YOLO/general_json2yolo.py", line 286, in convert_coco_json box = np.array(ann["bbox"], dtype=np.float64) KeyError: 'bbox'

Any idea on how to solve this error?

@glenn-jocher
Copy link
Member

@Mary14-design hello! 😊 It seems like there's an issue with accessing the bbox attribute in your annotations. This could happen if the JSON structure doesn't match what the script expects.

First, double-check the JSON file to ensure that it follows the COCO format, where each annotation should include a bbox field. The error might also occur if certain annotations are missing this field due to variability in the dataset.

If the structure is correct and the issue persists, you might want to add a check before accessing the bbox field to skip annotations without it:

if 'bbox' in ann:
    box = np.array(ann['bbox'], dtype=np.float64)
    # Proceed with your processing
else:
    print("Skipping annotation without bbox.")

This way, you can avoid the KeyError and handle annotations missing the bbox more gracefully.

For more detailed guidance on working with datasets and annotations, you might find the Ultralytics Docs helpful: https://docs.ultralytics.com

Let us know if you need further assistance!

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

2 participants