Public datasets are available from official websites or mirrors. If your folder structure is different, you may need to change the corresponding paths in config files.
scl
├── cfgs
├── lib
├── weights
├── data
│ ├── cityscape
│ │ ├── annos
│ │ ├── annos_multi
│ │ ├── imgs
│ │ ├── train.txt
│ │ ├── val.txt
│ │ ├── train_car.txt
│ │ ├── val_car.txt
│ ├── foggycity
│ │ ├── annos
│ │ ├── annos_multi
│ │ ├── imgs
│ │ ├── train.txt
│ │ ├── val.txt
│ │ ├── train_car.txt
│ │ ├── val_car.txt
| ├── watercolor
│ │ ├── Annotations
│ │ ├── ImageSets
│ │ │ ├── Main
│ │ │ | ├── train.txt
│ │ │ | ├── test.txt
│ │ ├── JPEGImages
| ├── sim10k
│ │ ├── Annotations
│ │ ├── JPEGImages
│ │ ├── train.txt
│ │ ├── val.txt
│ ├── VOCdevkit
│ │ ├── VOC2007
│ │ │ ├── Annotations
│ │ │ ├── JPEGImages
│ │ │ ├── ImageSets
│ │ ├── VOC2012
│ │ │ ├── Annotations
│ │ │ ├── JPEGImages
│ │ │ ├── ImageSets
We used two pretrained models in our experiments, VGG and ResNet101. You can download these two models from:
Download them and put them into the data/pretrained_model/.
The trained checkpoints can be accessed by Google drive.
As the code is a little old, both pytorch-0.4.0 and pytorch-1.0 (or higher) are needed.
Compile the cuda dependencies using following simple commands:
cd lib
# Under pytorch-0.4.0
sh make_1.sh
# Under pytorch-1.0
sh make_2.sh
To train a faster R-CNN model with vgg16 on sim10k, simply run:
python train_source.py \
--dataset sim10k --net vgg16 --bs $BATCH_SIZE
For citycape dataset, we first use cyclegan(https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix) to translate the source data into the style of target and then train a source model based on the new transferred source data.
python train_source.py \
--dataset cityscape --net vgg16 --bs $BATCH_SIZE
For watercolor dataset, feature alignment by adversarial training is performed to get the annotator.
python train_adv.py \
--dataset pascal_voc_0712_water --dataset_t watercolor --net res101 --bs $BATCH_SIZE
Extarct foreground features on sim10k:
python generate_gt_features.py --dataset sim10k --net vgg16 --r True --load_name $PATH_TO_ANNOTATOR
Extarct background features on sim10k:
python generate_bg_features.py --dataset sim10k --net vgg16 --r True --load_name $PATH_TO_ANNOTATOR
Learn dictionaries for foreground classes:
python learn_dicts.py
Learn background dictionaries by changing the settings in the 'learn_dicts.py' file.
python generate_inv_matrix.py
python generate_annos.py --dataset_t cityscape_car --net vgg16 --r True --load_name $PATH_TO_ANNOTATOR
When doing self-training, the annotations path should be changed in the definition of dataset class accordingly.
python train_cdg.py --dataset $DATASET_SOURCE --dataset_t $DATASET_TARGET --net $NET --bs $BATCH_SIZE
python test_net.py --dataset $DATASET --net $NET --r True --load_name $PATH_TO_ANNOTATOR