Skip to content

Accounting for class_id in cityscapes dataset #1064

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

Open
prabhuteja12 opened this issue Jun 28, 2019 · 6 comments
Open

Accounting for class_id in cityscapes dataset #1064

prabhuteja12 opened this issue Jun 28, 2019 · 6 comments

Comments

@prabhuteja12
Copy link

prabhuteja12 commented Jun 28, 2019

Hi,

In the dataset class for Cityscapes, the classes with their meta-data is mentioned as a namedtuple. However, this information is not used anywhere. Especially for semantic segmenation, the train_id should be used to convert the pixel value (of the label image) to the training label.

Is this planned to be added anytime soon?

Edit: There seems to have been a commit that does something like this and that hasn't been merged.
39a7a2f

@fmassa
Copy link
Member

fmassa commented Jun 28, 2019

For now, I'd recommend adding a transform that modifies the label to the desired format.

Before merging something like the PR you mentioned, we need to have a more structured way of addressing this.

@fmassa
Copy link
Member

fmassa commented Jun 28, 2019

also cc @TheCodez , as you have sent the original PRs

@TheCodez
Copy link
Contributor

TheCodez commented Jun 28, 2019

I would also recommend using a transform even when having some helper methods available.
For example like here: https://github.com/TheCodez/pytorch-GoogLeNet-FCN/blob/master/googlenet_fcn/datasets/transforms/transforms.py#L32-L37

@prabhuteja12
Copy link
Author

@TheCodez Thanks for the link! Thats looks great for my use!

@fmassa What do mean by structured way that you mentioned?

@RJT1990
Copy link
Contributor

RJT1990 commented Jun 29, 2019

Seconding @TheCodez approach.

I've been doing something similar-ish (but keeping the ID logic within the transform) - also using dual transforms logic.

class ConvertCityscapesIds(object):
    """Converts Cityscape masks - adds an ignore index"""

    def __init__(self, ignore_index):
        self.ignore_index = ignore_index

        self.id_to_trainid = {-1: ignore_index, 0: ignore_index, 1: ignore_index, 2: ignore_index, 3: ignore_index,
                              4: ignore_index, 5: ignore_index, 6: ignore_index, 7: 0, 8: 1, 9: ignore_index,
                              10: ignore_index, 11: 2, 12: 3, 13: 4, 14: ignore_index, 15: ignore_index, 16: ignore_index,
                              17: 5, 18: ignore_index, 19: 6, 20: 7, 21: 8, 22: 9, 23: 10, 24: 11, 25: 12, 26: 13, 27: 14,
                              28: 15, 29: ignore_index, 30: ignore_index, 31: 16, 32: 17, 33: 18}

    def __call__(self, image, target):

        target_copy = target.clone()

        for k, v in self.id_to_trainid.items():
            target_copy[target == k] = v

        return image, target_copy

@fmassa
Copy link
Member

fmassa commented Jul 2, 2019

Yes, the way @RJT1990 is how I do it myself as well.

@prabhuteja12 by structured way, I meant a similar comment as in #1067 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants