#Code for PCCL [Paper]. Based on the [ADVENT] paper and code.
- Python 3.7
- Pytorch >= 0.4.1
- CUDA 9.0 or higher
By default, the datasets are put in <root_dir>/../data
. We use symlinks to hook the ADVENT codebase to the datasets. An alternative option is to explicitlly specify the parameters DATA_DIRECTORY_SOURCE
and DATA_DIRECTORY_TARGET
in YML configuration files or if you want to fix them for all experiments modigy advent/domain_adaptation/config.py
.
- 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/GTAV/ % GTA dataset root
<root_dir>/data/GTAV/images/ % GTA images
<root_dir>/data/GTAV/labels/ % Semantic segmentation labels
...
- Cityscapes: Please follow the instructions in Cityscape 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
...
- Clone the repo:
$ git clone https://github.com/RobertoAlcoverCouso/PCCL/
$ cd ADVENT
- Install OpenCV if you don't already have it:
$ conda install -c menpo opencv
- Install this repository and the dependencies using pip:
$ pip install -e <root_dir>
With this, you can edit the code on the fly and import function and classes of ADVENT in other project as well.
- Optional. To uninstall this package, run:
$ pip uninstall ADVENT
You'll need at least image "frankfurt/frankfurt_000001_007973_leftImg8bit.png" in folder <root_dir>/data/Cityscapes/leftImg8bit and a download test_model.pth in <root_dir>/advent
$ cd <root_dir>/advent/scripts
$ python test.py --cfg configs/check.yml
For the experiments done in the paper, we used pytorch 0.4.1 and CUDA 9.0. To ensure reproduction, the random seed has been fixed in the code. However, you can select a random seed indicating with the flag --random-train
By default, logs and snapshots are stored in <root_dir>/experiments
with this structure:
<root_dir>/experiments/logs
<root_dir>/experiments/snapshots
$ cd <root_dir>/advent/scripts
$ python train.py --cfg ./configs/Pre_defined.yml
$ python train.py --cfg ./configs/Pre_defined.yml --tensorboard % using tensorboard
For a given UDA method ``method":
$ cd <root_dir>/advent/scripts
$ python train.py --cfg ./configs/method.yml
$ python train.py --cfg ./configs/method.yml --tensorboard % using tensorboard
If multiple GPUs are available, you can denote it by:
$ python train.py --cfg ./configs/method.yml -n N -g G -r R
where N is the number of nodes, G the number of gpus per node and r the rank of each process. make sure to tune the variables: os.environ['MASTER_ADDR'], os.environ['MASTER_PORT'] to your machine.
To test a given method ``method":
$ cd <root_dir>/advent/scripts
$ python test.py --cfg ./configs/method.yml
We provide the links of our trained models:
advent/domain_adaptation/train_UDA.py contains the implementation of each method.
advent/model/* contains the implementation of DeplabV2 and the discriminator.
advent/scripts/train.py contains the higher level code for defining the datasets, loaders and training method.