Skip to content

COCO.loadRes: copy the info dict to the results too #26

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

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

carandraug
Copy link
Contributor

The COCO.loadRes returns a new COCO object with the results. It does this by copying the images and categories fields from the COCO data object. However, it does not copy the info dict. The end result is that the info() method in the returned results COCO fails:

>>> coco_res = coco_data.loadRes(...)
>>> coco_res.info()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/site-packages/pycocotools/coco.py", line 124, in info
    for key, value in self.dataset['info'].items():
                      ~~~~~~~~~~~~^^^^^^^^
KeyError: 'info'

ThIs PR copies the original info field so things work. I'm not sure if it is the best choice since the results should maybe have a different "info" but there is no "info" on the results file so this seems the best option to prevent errors without changing the API.

@ppwwyyxx ppwwyyxx merged commit 617836c into ppwwyyxx:master Aug 13, 2024
21 checks passed
@carandraug carandraug deleted the include-info-on-results branch August 13, 2024 14:10
bertsky pushed a commit to bertsky/cocoapi that referenced this pull request May 13, 2025
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

Successfully merging this pull request may close these issues.

2 participants