Pytorch implementation of our paper On exploring weakly supervised domain adaptation strategies for semantic segmentation using synthetic data.
- Python 3.7
- Pytorch >= 0.4.1
- CUDA 9.0 or higher
- Clone the repo:
$ git clone https://github.com/RobertoAlcoverCouso/OEWSDA
$ cd OEWSDA
- Create a conda environment:
$ conda create -n OEWSDA python=3.7
$ conda activate OEWSDA
- Install OpenCV and pytorch if you don't already have it:
$ conda install pytorch=0.4.1 cuda90 torchvision -c pytorch
$ conda install -c menpo opencv
- Install this repository and the dependencies using pip
<root_dir>
stands for./
if you follow the instructions:
$ pip install -e <root_dir>
By default, the datasets are put in <root_dir>/../data
. An alternative option is to explicitlly specify the parameters in the cfg file.
- GTA5: Please follow the instructions here to download images and semantic segmentation annotations. The GTA5 dataset directory should have this basic structure:
<root_dir>/../data/GTA5/ % GTA dataset root
<root_dir>/../data/GTA5/images/ % GTA images
<root_dir>/../data/GTA5/labels/ % Semantic segmentation labels
...
- Cityscapes: Please follow the instructions in Cityscapes to download the images and validation ground-truths. The Cityscapes dataset directory should have this basic structure:
<root_dir>/../data/Cityscapes/ % Cityscapes dataset root
<root_dir>/../data/Cityscapes/leftImg8bit % Cityscapes images
<root_dir>/../data/Cityscapes/leftImg8bit/val
<root_dir>/../data/Cityscapes/gtFine % Semantic segmentation labels
<root_dir>/../data/Cityscapes/gtFine/val
...
For each dataset analized, there is a <dataset_name>_utils.py file in the <root_dir>/dataset folder. This file will transform the semantic labels to the Cityscapes train labels to be employed. For example for the Cityscapes dataset:
$ python dataset/cityscapes_utils.py
This should have created 3 csvs for each of the subsets: "trainCS.csv", "valCS.csv" and "testCS.csv"
- Model weights: If you intend on using deeplab please download the imagenet-pretrained backbone weights.
Additional weights can be found in the publication page
- Train: Modify the yalm file corresponding to the experiment you want to run "<experiment_name>.yalm" to include the datasets you want to train with, the proportion to use in the range of 0-1 as follows and the model you want to use as follows:
architecture: <architecture_name>
train_set:
<dataset_1>: <proportion_of_dataset_1>
<dataset_2>: <proportion_of_dataset_2>
...
<architecture_name> is expected to be one of the following: "deeplabv3","FCN" or "psp" To train run the command line:
python main.py --config config/<experiment_name>.yalm
Note that for fine_tuning a restore file is expected in the "restore_file" argument.
run the command line:
python main.py -r <model_to_validate> --config config/validate.yalm