Skip to content

Latest commit

 

History

History
184 lines (161 loc) · 4.48 KB

README.md

File metadata and controls

184 lines (161 loc) · 4.48 KB

Prepare Datasets for HGFormer

A dataset can be used by accessing DatasetCatalog for its data, or MetadataCatalog for its metadata (class names, etc). This document explains how to setup the builtin datasets so they can be used by the above APIs. Use Custom Datasets gives a deeper dive on how to use DatasetCatalog and MetadataCatalog, and how to add new datasets to them.

HGFormer has builtin support for a few datasets. The datasets are assumed to exist in a directory specified by the environment variable DETECTRON2_DATASETS. Under this directory, detectron2 will look for datasets in the structure described below, if needed.

$DETECTRON2_DATASETS/
  cityscapes/
  cityscapes-c/
  mapillary/
  acdc/
  bdd/
  gta/
  synthia/

You can set the location for builtin datasets by export DETECTRON2_DATASETS=/path/to/datasets. If left unset, the default is ./datasets relative to your current working directory.

Expected dataset structure for cityscapes:

cityscapes/
  gtFine/
    train/
      aachen/
        color.png, instanceIds.png, labelIds.png, polygons.json,
        labelTrainIds.png
      ...
    val/
    test/
  leftImg8bit/
    train/
    val/
    test/

Install cityscapes scripts by:

pip install git+https://github.com/mcordts/cityscapesScripts.git

Note: to create labelTrainIds.png, first prepare the above structure, then run cityscapesescript with:

CITYSCAPES_DATASET=/path/to/abovementioned/cityscapes python cityscapesscripts/preparation/createTrainIdLabelImgs.py

Expected dataset structure for ACDC:

acdc/
    rgb_anon/
        fog/
            test/
        night/
            test/
        rain/
            test/
        snow/
            test/
        all/
            test/
    

You should create the folder of all and copy test images of all types to all/test

Expected dataset structure for Mapillary:

mapillary/
    training/
        images/
        labels
    validation/
        images/
        labels/
    testing/
        images/
        labels/
    labels_detectron2/
        training/
        validation/

Run python datasets/prepare_mapillary_sem_seg.py, to map the mapillary labels to the Cityscapes labels

Expected dataset structure for BDD:

bdd/
    images/
        10k/
          train/
          val/
    labels/
        sem_seg/
          masks/
            train/
            val/

Expected dataset structure for Cityscapes-c:

cityscapes-c/
     clean/
     brightness/
        1/
        2/
        3/
        4/
        5/
     ...

The folder clean should include the cityscapes images of val set.

The folders of corruption types (e.g. brightness) are generated by run python datasets/generate_cityscapes_c.py

Expected dataset structure for GTAV:

gta/
    images/
        train/
        valid/
        test/
    labels/
        train/
        valid/
        test/
    labels_detectron2/
        train/
        valid/
        test/

Downlaod the GTA from https://download.visinf.tu-darmstadt.de/data/from_games/

Then unzip the images and labels.

We split the dataset following RobustNet

python datasets/split_data/gta/split_gta.py

For the GTA dataset, a small set of label maps (60 frames) has a different resolution than their corresponding image. Therefore, we need to resize these label maps.

python datasets/split_data/gta/resize_img.py
mv datasets/GTA/labels/valid_resize/* datasets/GTA/labels/valid/
rm -rf datasets/GTA/labels/valid_resize/

Finally, we map the labels for detectron2:

python datasets/prepare_gta_sem_seg.py

Expected dataset structure for Synthia:

synthia/
    Depth/
        Depth
    GT/
        COLOR/
        LABELS/
            train/
            val/
    RGB/
        train/
        val/

We follow the RobustNet to split the dataset.

python datasets/synthia/split_synthia.py

We then map the labels from synthia to cityscapes.

python datasets/prepare_synthia_sem_seg.py