Skip to content

RobertoAlcoverCouso/PCCL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#Code for PCCL [Paper]. Based on the [ADVENT] paper and code.

Preparation

Pre-requisites

  • Python 3.7
  • Pytorch >= 0.4.1
  • CUDA 9.0 or higher

Data downlading

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
...

Installation

  1. Clone the repo:
$ git clone https://github.com/RobertoAlcoverCouso/PCCL/
$ cd ADVENT
  1. Install OpenCV if you don't already have it:
$ conda install -c menpo opencv
  1. 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.

  1. Optional. To uninstall this package, run:
$ pip uninstall ADVENT

Check Installation

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

Training

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

Training source model

$ cd <root_dir>/advent/scripts
$ python train.py --cfg ./configs/Pre_defined.yml
$ python train.py --cfg ./configs/Pre_defined.yml --tensorboard         % using tensorboard

Training UDA model

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.

Testing

To test a given method ``method":

$ cd <root_dir>/advent/scripts
$ python test.py --cfg ./configs/method.yml

Pretrained Models

We provide the links of our trained models:

  1. AdaptSegNet
  2. ADVENT
  3. MinEnt
  4. FADA
  5. MAXSquare

Important files

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages