Git Product home page Git Product logo

mseg-api's Introduction

Linux CI

Creative Commons License

This is the code for the paper:

MSeg: A Composite Dataset for Multi-domain Semantic Segmentation (CVPR 2020, Official Repo) [CVPR PDF] [TPAMI Journal PDF]
John Lambert*, Zhuang Liu*, Ozan Sener, James Hays, Vladlen Koltun
Presented at CVPR 2020. Link to MSeg Video (3min)

NEWS:

  • [Dec. 2021]: An updated journal-length version of our work is now available on ArXiv here.

This repo is the first of 4 repos that introduce our work. It provides utilities to download the MSeg dataset (which is nontrivial), and prepare the data on disk in a unified taxonomy.

Three additional repos are also provided:

  • mseg-semantic: provides HRNet-W48 Training (sufficient to train a winning entry on the WildDash benchmark)
  • mseg-panoptic: provides Panoptic-FPN and Mask-RCNN training, based on Detectron2 (will be introduced in January 2021)
  • mseg-mturk: utilities to perform large-scale Mechanical Turk re-labeling

Install the MSeg module:

  • mseg can be installed as a python package using

      pip install -e /path_to_root_directory_of_the_repo/
    

Make sure that you can run import mseg in python, and you are good to go!

Download MSeg

The MSeg Taxonomy

We provide comprehensive class definitions and examples here. We provide here a master spreadsheet mapping all training datasets to the MSeg Taxonomy, and the MSeg Taxonomy to test datasets. Please consult taxonomy_FAQ.md to learn what each of the dataset taxonomy names means.

Citing MSeg

If you find this code useful for your research, please cite:

@InProceedings{MSeg_2020_CVPR,
author = {Lambert, John and Liu, Zhuang and Sener, Ozan and Hays, James and Koltun, Vladlen},
title = {{MSeg}: A Composite Dataset for Multi-domain Semantic Segmentation},
booktitle = {Computer Vision and Pattern Recognition (CVPR)},
year = {2020}
}

@article{Lambert23tpami_MSeg,
  author={Lambert, John and Liu, Zhuang and Sener, Ozan and Hays, James and Koltun, Vladlen},
  journal={IEEE Transactions on Pattern Analysis and Machine Intelligence}, 
  title={MSeg: A Composite Dataset for Multi-Domain Semantic Segmentation}, 
  year={2023},
  volume={45},
  number={1},
  pages={796-810},
  doi={10.1109/TPAMI.2022.3151200}
}

Repo Structure

  • download_scripts: code and instructions to download the entire MSeg dataset
  • mseg: Python module, including
    • dataset_apis
    • dataset_lists: ordered classnames for each dataset, and corresponding relative rgb/label file paths
    • label_preparation: code for remapping to semseg format, and for relabeling masks in place
    • relabeled_data: MSeg data, annotated by Mechanical Turk workers, and verified by co-authors
    • taxonomy: on-the-fly mapping to a unified taxonomy during training, and linear mapping to evaluation taxonomies
    • utils: library functions for mask and image manipulation, filesystem, tsv/csv reading, and multiprocessing
  • tests: unit tests on all code

Data License

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

Frequently Asked Questions (FAQ)

Q: Do the weights include the model structure or it's just the weights? If the latter, which model do these weights refer to? Under the models directory, there are several model implementations.

A: The pre-trained models follow the HRNet-W48 architecture. The model structure is defined in the code here. The saved weights provide a dictionary between keys (unique IDs for each weight identifying the corresponding layer/layer type) and values (the floating point weights).

Q: How is testing performed on the test datasets? In the paper you talk about "zero-shot transfer" -- how this is performed? Are the test dataset labels also mapped or included in the unified taxonomy? If you remapped the test dataset labels to the unified taxonomy, are the reported results the performances on the unified label space, or on each test dataset's original label space? How did you you obtain results on the WildDash dataset - which is evaluated by the server - when the MSeg taxonomy may be different from the WildDash dataset.

A: Regarding "zero-shot transfer", please refer to section "Using the MSeg taxonomy on a held-out dataset" on page 6 of our paper. This section describes how we hand-specify mappings from the unified taxonomy to each test dataset's taxonomy as a linear mapping (implemented here in mseg-api). All results are in the test dataset's original label space (i.e. if WildDash expects class indices in the range [0,18] per our names_list, our testing script uses the TaxonomyConverter transform_predictions_test() functionality to produce indices in that range, remapping probabilities.

Q: Why don't indices in MSeg_master.tsv match the training indices in individual datasets? For example, for the road class: In idd-39, road has index 0, but in idd-39-relabeled, road has index 19. It is index 7 in cityscapes-34. The cityscapes-19-relabeled index road is 11. As far as I can tell, ultimately the 'MSeg_Master.tsv' file provides the final mapping to the MSeg label space. But here, the road class seems to have an index of 98, which is neither 19 nor 11.

A: Indeed, unified taxonomy class index 98 represents "road". But we use the TaxonomyConverter to accomplish the mapping on the fly from idd-39-relabeled to the unified/universal taxonomy (we use the terms "unified" and "universal" interchangeably). This is done by adding a transform in the training loop that calls TaxonomyConverter.transform_label() on the fly. You can see how that transform is implemented here in mseg-semantic.

Q: When testing, but there are test classes that are not in the unified taxonomy (e.g. Parking, railtrack, bridge etc. in WildDash), how do you produce predictions for that class? I understand you map the predictions with a binary matrix. But what do you do when there's no one-to-one correspondence?

A: WildDash v1 uses the 19-class taxonomy for evaluation, just like Cityscapes. So we use the following script to remap the 34-class taxonomy to 19-class taxonomy for WildDash for testing inference and submission. You can see how Cityscapes evaluates just 19 of the 34 classes here in the evaluation script and in the taxonomy definition. However, bridge and rail track are actually included in our unified taxonomy, as you’ll see in MSeg_master.tsv.

Q: How are datasets images read in for training/inference? Should I use the dataset_apis from mseg-api?

A: The dataset_apis from mseg-api are not for training or inference. They are purely for generating the MSeg dataset labels on disk. We read in the datasets using mseg_semantic/utils/dataset.py and then remap them to the universal space on the fly.

mseg-api's People

Contributors

johnwlambert avatar mseg-dataset avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mseg-api's Issues

MSEG CamVid test set: is listed but not remapped?

I noticed that for camvid the test set seems to be listed (ie the TSV file camvid-11/list/test.txt exists).

However after downloading and remapping, the semseg11 segmentation mask is missing (eg semseg11/0001TP_008550_L.png is missing), while the original 32 class segmentation mask does exists (Labels32-RGB/0001TP_008550_L.png).

How can I remap the test set as well?

Mapillary dataset

The current mapillary dataset available in the official webpage is version 2.0.
Download instructions are based on v1.1 .

BDD dataset info

Downloading instruction is stating:
"This dataset is not available via wget, so we ask that you download it in a browser, and upload it (1.3 GB) to the desired location on your server.

Log in, click the "Download" tab on the left, accept terms, then click the link for "Segmentation" (file should appear under name "bdd100k_seg.zip")"

When I try to download the file size is ~300Mb and also its name is bdd100k_sem_seg_labels_trainval. There is no file with 1.3G size and the name bdd100k_seg.zip on BDD official page (https://bdd-data.berkeley.edu/login.html)

Can't download ADE20K_2016_07_26.zip

Hi, thanks very much for your nice work. currently, I just follow your instructions and it reports that :
Archive: ADE20K_2016_07_26.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.

Really Nice Work!

Really nice work and I hope you could release the remained 3 repos so that the community could conduct research along this direction.

This repo is the first of 4 repos that introduce our work. It provides utilities to download the MSeg dataset (which is nontrivial), and prepare the data on disk in a unified taxonomy.

In a few weeks, we will add the TaxonomyConverter class to this repo that supports on-the-fly mapping to a unified taxonomy during training.

Can't find supplement mentioned in paper

Hi, I'm having a hard time finding the supplement material described in the paper. In a previous issue you mentioned that it will get updated to arxiv but I can't find it there. Can you let me know where should I search for this document?

Thanks!

Final taxonomy

Hello,

thank you for interesting work.

I have a question regarding the final class name -> id mapping.
How can one obtain such mapping using the mseg-api?
Are the label IDs sorted alphabetiaclly according to the universal column?

Problem with COCOPanoptic dataset

Hello I have some problem with remap and relabelling of COCOPanoptic dataset. Firstly I needed to download it separately due to some script problem.

First here is error from remap log, but the script completed 100% train and validation 0%.
image

Second error in relabeling log. it also says it has completed 100% train and validation 0%.
image
image

After this I tried to run the unit test, and it crashes at cocopanoptic dataset.
image

Thank you for your nice work

Thank you for your nice work.
I want to run your models on my own test datasets.
Would you add instruction for how to run your model?

Reintroducing the crosswalk class back into MSeg

Hello,
I want to re-add the crosswalk class to the MSeg dataset. I have seen that mapillary vistas dataset contains the crosswalk class, and that it is relabeled to the road class. Also, I know that other datasets (such as cityscapes) contains crosswalks but they are not labeled and are considered plain road. My question is: How would you add the crosswalk class back into the dataset? . I'm thinking of 3 options, and I would appreciate your insight:

  1. Use mseg-turk to label each dataset which does not contain crosswalks. This might be the best and most straight-forward option, but this can prove labor-intensive and costly
  2. For the datasets that do not contain crosswalks, ignore the road class. For example, ignore all possible mislabels of crosswalks in the cityscapes dataset. I expect this to lower the confidence for the road class, as there will be considerably less data.
  3. Simply add the crosswalk class and revert the relabel action applied on mapillary. I woudn't try this, because it might be problematic for the model to learn crosswalks only sometimes (in case of mapillary frames) while ignoring them alltogether in other cases(e.g. cityscapes frames) - which may also create confusion between the road class and crosswalk class.

Thanks!

Where is supplement mentioned in the paper

Hello, I want to know the datasets that were not used in MSeg and the reasons for not including them. However, I can not find supplement through google. Can you give me the link of supplement?

Trying to reduce the number of classes of Mseg

Hi, @johnwlambert I want to make something similar with the dataset (as mentioned by someone in the issues, who wanted to add crosswalk), but also add curb and curb cut. So for this until now i figured out, that I should modify the tsv files of dataset you mentioned above. But I dont know if this is complete, so I have two questions:

  • When you said add 'crosswalk' to universal taxonomy you refer to add a new line in MSeg_master.tsv for this class? I should do this also for, curb (curb, curb cut)? are there other files, i should change?

  • I want to keep only 64 classes, so this means I only remove them (their lines) from MSeg_master.tsv and add to final line to unlabeled, and also modify the tsv file for every dataset (ex. ade20k-151_to_ade20k-150.tsv and ade20k-151_to_ade20k-150-relabeled.tsv).

Until now I changed MSeg_master.tsv to have my selected classes, and move the other to unlabeled, and then also changed the state in every 'name_of_dataset.tsv' to unlabeled for the deleted one.
I run, remap functions and everything works ok. But when I try to relabel, on ade_20k it worked, but stopped on BDD. When I run with old bdd.tsv works, with the new tsv it catch an assert:

File "/home/ubuntu/data/datasets/mseg/mseg_files/mseg-api/mseg/utils/mask_utils.py", line 920, in swap_px_inside_mask assert np.allclose(np.unique(label_img[y,x]), np.array([old_val], dtype=np.uint8))

This is the new bdd.tsv:
bdd bdd-relabeled
building building
road road
sidewalk sidewalk_pavement
terrain terrain
person unlabeled
rider rider_other
traffic sign traffic_sign
traffic light traffic_light
sky sky
pole unlabeled
fence unlabeled
vegetation vegetation
bicycle bicycle
car car
motorcycle motorcycle
bus bus
train unlabeled
truck unlabeled
wall wall
unlabeled unlabeled

Waiting for you response.

WildDash download and extraction scripts

The WildDash download script fetches 'wd_bench_01.zip' and 'wd_val_01.zip' but the extraction script uses 'wd_both_01.zip' and 'wd_val_01.zip'. Manually downloading 'wd_both_01.zip' instead of 'wd_bench_01.zip' seems to work with the following remapping.

Error in dataset path verification

When I try to run the verification script

python -u ../tests/verify_all_dataset_paths_exist.py

I get the following error:

Finding matches for cityscapes-19-relabeled...
Finding matches for ade20k-150-relabeled...
Finding matches for bdd-relabeled...
Finding matches for coco-panoptic-133-relabeled...
Finding matches for idd-39-relabeled...
Finding matches for sunrgbd-37-relabeled...
Finding matches for mapillary-public65-relabeled...
Writing visual sanity checks for ade20k-151-inst...
Writing visual sanity checks for ade20k-151...
On 0 of ade20k-151
Traceback (most recent call last):
  File "../tests/verify_all_dataset_paths_exist.py", line 250, in <module>
    visual_sanitychecks()
  File "../tests/verify_all_dataset_paths_exist.py", line 94, in visual_sanitychecks
    id_to_class_name_map=id_to_classname_map
  File "/<path>/mseg-api/mseg/utils/mask_utils_detectron2.py", line 477, in overlay_instances
    class_mode_idx = get_most_populous_class(segment_mask, label_map)
  File "/<path>/mseg-api/mseg/utils/mask_utils.py", line 992, in get_most_populous_class
    class_mode_idx = get_np_mode(class_indices)
  File "/<path>/mseg-api/mseg/utils/mask_utils.py", line 931, in get_np_mode
    return np.argmax(counts)
  File "<__array_function__ internals>", line 6, in argmax
  File "/<path>/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 1186, in argmax
    return _wrapfunc(a, 'argmax', axis=axis, out=out)
  File "/<path>/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 61, in _wrapfunc
    return bound(*args, **kwds)
ValueError: attempt to get argmax of an empty sequence

Additonally adding 'ade20k-151', 'ade20k-150', and 'ade20k-150-relabeled' in line 58 to skip them, leads to the same error thrown for the BDD dataset. Thus, the error doesn't seem to be dataset specific.

I'm running python 3.7.6 and numpy 1.18.2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.