question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accounting for class_id in cityscapes dataset

See original GitHub issue

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. https://github.com/pytorch/vision/pull/1025/commits/39a7a2fb6015792b6c32fd7ee3eeac9774f712a4

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
RJT1990commented, 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
1reaction
TheCodezcommented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Benchmark Suite - Cityscapes Dataset
scale features into account. For the second issue, we design an edge-aware loss which is effective in distinguishing the boundaries of object/stuff.
Read more >
Partial results of the Cityscapes dataset - ResearchGate
Recently, Deep Neural Network (DNN) has been used to solve the problem of object detection and classification, road detection, and image semantic segmentation ......
Read more >
Understanding Cityscapes: Efficient Urban Semantic Scene ...
Activity statistics for Cityscapes dataset over ... From a high-level perspective, classic methods for semantic label-.
Read more >
A Beginner's guide to Deep Learning based Semantic ...
In the segmentation images, the pixel value should denote the class ID of the corresponding pixel. This is a common format used by...
Read more >
Semantic Segmentation Tutorial - Analytics Vidhya
This is a classic example of semantic segmentation at work. ... Preparing the dataset: For training the DeepLab model on our custom dataset, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found