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

Implementation for cityscapes in proto datasets #5441

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

vfdev-5
Copy link
Collaborator

@vfdev-5 vfdev-5 commented Feb 18, 2022

Fixes #5353

Related to #5336

Description:

  • Implementation for cityscapes in proto datasets

@facebook-github-bot
Copy link

facebook-github-bot commented Feb 18, 2022

💊 CI failures summary and remediations

As of commit 5c8850b (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@vfdev-5 vfdev-5 force-pushed the fix-5353-add-cityscapes branch 2 times, most recently from b94bb3d to 7b40f9c Compare February 18, 2022 16:53
@vfdev-5 vfdev-5 force-pushed the fix-5353-add-cityscapes branch 5 times, most recently from b3f4c0a to 71e0d26 Compare February 21, 2022 14:10
@vfdev-5 vfdev-5 marked this pull request as ready for review February 21, 2022 15:45
@vfdev-5 vfdev-5 requested a review from pmeier February 21, 2022 15:46
Copy link
Contributor

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Thanks @vfdev-5. I have a few questions and mostly simplifications inline.

torchvision/prototype/datasets/_builtin/cityscapes.py Outdated Show resolved Hide resolved
torchvision/prototype/datasets/_builtin/cityscapes.py Outdated Show resolved Hide resolved
torchvision/prototype/datasets/_builtin/cityscapes.py Outdated Show resolved Hide resolved
torchvision/prototype/datasets/_builtin/cityscapes.py Outdated Show resolved Hide resolved
torchvision/prototype/datasets/_builtin/cityscapes.py Outdated Show resolved Hide resolved
torchvision/prototype/datasets/_builtin/cityscapes.py Outdated Show resolved Hide resolved
torchvision/prototype/datasets/_builtin/cityscapes.py Outdated Show resolved Hide resolved
torchvision/prototype/datasets/_builtin/cityscapes.py Outdated Show resolved Hide resolved

categories_to_details: FrozenMapping = FrozenMapping(
{
"unlabeled": CityscapesClass("unlabeled", 0, 255, "void", 0, False, True, (0, 0, 0)),
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems, all of this information is exposed to the user, but never used internally. Is this just static information or would it make sense to include it in the samples?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is used in extra=dict(classname_to_details=self.categories_to_details), and is exposed to the user as in the previously implementation

Copy link
Contributor

Choose a reason for hiding this comment

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

My point is: what does the user do with this information? I reckon color is useful to parse a segmentation mask. The category looks like what we called super_category in COCO. So maybe we can just provide two dictionaries in the extra information that map the category to its color and super category respectively?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

CityscapesClass provides more info that just color, category name, super category. It may happen that users could use other fields for visualization purposes and thus new dataset would miss that info.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the stable API this is exposed through the undocumented torchvision.datasets.Cityscapes(...).classes attribute. Given that the new API is BC breaking anyway, IMO we should aim to reduce the baggage from the old implementation. I indeed see use cases for returning a color to category mapping (maybe we should have this on the SegmentationMask feature) as well as the category to super category mapping. For the rest I would remove them for now and only put them back if someone requests it. cc @NicolasHug for an opinion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is dataset meta-data, probably coming from https://github.com/mcordts/cityscapesScripts and is used for visualization (this can be seen by searching through the GitHub and exploring repository by repository, https://github.com/search?p=1&q=CityscapesClass&type=Code). Even if this wasn't explicitly documented previously, I do not think that we have to remove that in the new API.

Copy link
Member

Choose a reason for hiding this comment

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

I would remove them for now and only put them back if someone requests it.

I'm happy with that.

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Feb 21, 2022

@pmeier thanks for the review

@vfdev-5 vfdev-5 requested a review from pmeier February 24, 2022 14:30

categories_to_details: FrozenMapping = FrozenMapping(
{
"unlabeled": CityscapesClass("unlabeled", 0, 255, "void", 0, False, True, (0, 0, 0)),
Copy link
Contributor

Choose a reason for hiding this comment

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

My point is: what does the user do with this information? I reckon color is useful to parse a segmentation mask. The category looks like what we called super_category in COCO. So maybe we can just provide two dictionaries in the extra information that map the category to its color and super category respectively?

torchvision/prototype/datasets/_builtin/cityscapes.py Outdated Show resolved Hide resolved
Comment on lines +141 to +144
def _filter_split_images(self, data: Tuple[str, Any], *, req_split: str) -> bool:
path = Path(data[0])
split = path.parent.parts[-2]
return split == req_split and ".png" == path.suffix
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer the granularity given that the performance overhead from this hardly will make any difference. cc @NicolasHug for an opinion.

if target_type == "polygon":
enc_data = json.loads(data.read())
else:
enc_data = EncodedImage.from_file(data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder for self: we need an EncodedSegmentationMask feature now that we also have a separate SegementationMask.

test/builtin_dataset_mocks.py Outdated Show resolved Hide resolved
test/builtin_dataset_mocks.py Outdated Show resolved Hide resolved
test/builtin_dataset_mocks.py Outdated Show resolved Hide resolved
test/builtin_dataset_mocks.py Outdated Show resolved Hide resolved
test/builtin_dataset_mocks.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cityscapes
4 participants