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

allow convert_to_coco_dict for custom dataset without annotations #1683

Closed
wants to merge 1 commit into from

Conversation

wangg12
Copy link
Contributor

@wangg12 wangg12 commented Jun 26, 2020

Fix #1684 . Allowing inference when annotations are not available for custom datasets.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 26, 2020
@ppwwyyxx
Copy link
Contributor

Please describe the problem first. Currently, the issue is empty.

@wangg12
Copy link
Contributor Author

wangg12 commented Jun 27, 2020

I think the issue already describes the problem clearly:)

@ppwwyyxx
Copy link
Contributor

An easier solution is to let convert_to_coco_json support dataset without annotations (instead of throwing an error). That should be doable with <5 lines.

@wangg12
Copy link
Contributor Author

wangg12 commented Jun 27, 2020

Maybe using

anns_per_image = image_dict.get("annotations", [])

in https://github.com/facebookresearch/detectron2/blob/master/detectron2/data/datasets/coco.py#L321.
I'm not sure if this is sufficient.

@wangg12
Copy link
Contributor Author

wangg12 commented Jun 27, 2020

I tested this, it works for me by just changing one line.

@ppwwyyxx
Copy link
Contributor

Not sure whether

"annotations": coco_annotations,
needs to be changed as well, given this line in evaluator:
self._do_evaluation = "annotations" in self._coco_api.dataset

@wangg12 wangg12 changed the title allow inference without evaluation for custom dataset allow convert_to_coco_dict for custom dataset without annotations Jun 27, 2020
@wangg12
Copy link
Contributor Author

wangg12 commented Jun 27, 2020

By doing this, the evaluation will still be performed. But got all nan results.

@wangg12
Copy link
Contributor Author

wangg12 commented Jun 27, 2020

Now it should be fine. If there are no annotations at all, the converted coco json file will not contain "annotations".

Copy link
Contributor

@ppwwyyxx ppwwyyxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ppwwyyxx is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@ppwwyyxx merged this pull request in 0f09111.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(coco-style) Inference fails for custom dataset without annotations
3 participants