Code Monkey home page Code Monkey logo

ccm's Introduction

[ECCV20] Content-Consistent Matching for Domain Adaptive Semantic Segmentation

This is a PyTorch implementation of CCM.

News: GTA-4K list is available!

A smaller subset of GTA5 dataset that shares higher layout similarites with Cityscapes.

Prerequisites

To install requirements:

pip install -r requirements.txt
  • Python 3.6
  • GPU Memory: 24GB for the first stage(Source-only Model), and 12GB for the second stage
  • Pytorch 1.4.0

Getting Started

  1. Download the dataset GTA5 and Cityscapes.
  2. Download the ImageNet-pretrained Model [Link].
  3. Download the Source-only Model Link.

Training

To train the source-only model:

CUDA_VISIBLE_DEVICES=0 python so_run.py

To train the adaptation model:

CUDA_VISIBLE_DEVICES=0 python run.py

Evaluation

To perform evaluation on a multiple models under a directory:

python eval.py --frm your_dir 

To perform evaluation on single model:

python eval.py --frm model.pth --single

Citation

If you find it helpful, please consider citing:

@inproceedings{li2020content,
  title={Content-consistent matching for domain adaptive semantic segmentation},
  author={Li, Guangrui and Kang, Guoliang and Liu, Wu and Wei, Yunchao and Yang, Yi},
  booktitle={European Conference on Computer Vision},
  pages={440--456},
  year={2020},
  organization={Springer}
}

ccm's People

Contributors

dependabot[bot] avatar solacex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ccm's Issues

Questions about the two models

Hi
  I am a little confused about these two models, the ImageNet-pretrained Model and the Source-only Model. Why does the Source-only Model appear in this ccm_config.yml file?CCM and Source only, aren't they two different methods ?

init_weight: './gta5_source_only.pth'

  In addition, from the section 4.2 of paper, "We start from DeepLabV2-Res101with the backbone pretrained on the ImageNet. Then we firstly finetune the whole network on the source data and use such a source-trained network to initialize the target (adaptation) model.", The ImageNet-pretrained Model should be the adaption model. I am a little confused. THANKS!
  PS: There is a bug with 'News: GTA-4K list is avalible!'.

neptune.exceptions.MissingApiToken: Missing API token.

for the below three rows:
if self.config.neptune:
neptune.init(project_qualified_name="solacex/segmentation-DA")
neptune.create_experiment(params=self.config, name=self.config["note"])

get the below rseult:
neptune.exceptions.MissingApiToken: Missing API token. Use "NEPTUNE_API_TOKEN" environment variable or pass it as an argument

it's so strange for me, can you tell me how to tackle this problem?

The random selection of 'pool_prop' before matching and selection

Hi there,

Thanks for your code!

I ran the code and only got 48.8 mIoU which is 1 mIoU inferior to the reported one in the paper.

I found that the code randomly selects part of the source dataset at each round before conducting image selection. And 'pool_prop' in ccm_config.yml determines this proportion, namely, 20% in default. Then around 1k images are selected from the remained 20% images.

Would this random selection process affect the performance? And is it enough to use only 1k source images for the training during each epoch? What is the best set of these hyper-parameters?

Training error: RuntimeError: For non-complex input tensors, argument alpha must not be a complex number.

Hi, thanks for your great jobs!
When I try to train a model, there was an error like that:


Traceback (most recent call last):
File "so_run.py", line 51, in
main()
File "so_run.py", line 43, in main
trainer.train()
File "/home/CCM/trainer/source_only_trainer.py", line 58, in train
self.optim.step()
File /home/anaconda3/envs/torch1.9/lib/python3.8/site-packages/torch/optim/optimizer.py", line 88, in wrapper
return func(*args, **kwargs)
File "/home/anaconda3/envs/torch1.9/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
return func(*args, **kwargs)
File "/home/anaconda3/envs/torch1.9/lib/python3.8/site-packages/torch/optim/sgd.py", line 110, in step
F.sgd(params_with_grad,
File "/home/anaconda3/envs/torch1.9/lib/python3.8/site-packages/torch/optim/functional.py", line 180, in sgd
param.add
(d_p, alpha=-lr)
RuntimeError: For non-complex input tensors, argument alpha must not be a complex number.


How should I fix it? Thank you.
And my config used to train is:


note: 'train'

configs of data

model: 'deeplab'
train: True
multigpu: False
fixbn: True
fix_seed: True

Optimizaers

learning_rate: 7.5e-5
num_steps: 5000
epochs: 2
weight_decay: 0.0005
momentum: 0.9
power: 0.9
round: 6

Logging

print_freq: 1
save_freq: 2000
tensorboard: False
neptune: False
screen: True
val: False
val_freq: 300

Dataset

source: 'gta5'
target: 'cityscapes'
worker: 0
batch_size: 2

#Transforms
input_src: 720
input_tgt: 720
crop_src: 600
crop_tgt: 600
mirror: True
scale_min: 0.5
scale_max: 1.5
rec: False

Model hypers

init_weight: './pretrained/DeepLab_resnet_pretrained_init-f81d91e8.pth'
restore_from: None

snapshot: './Data/snapshot/'
result: './miou_result/'
log: './log/'
plabel: './plabel'
gta5: {
data_dir: '/home/data/datasets/GTA5/',
data_list: './dataset/list/gta5_list.txt',
input_size: [1280, 720]
}
synthia: {
data_dir: '/home/guangrui/data/synthia/',
data_list: './dataset/list/synthia_list.txt',
input_size: [1280, 760]
}
cityscapes: {
data_dir: '/home/data/datasets/Cityscapes',
data_list: './dataset/list/cityscapes_train.txt',
input_size: [1024, 512]
}

Source Only Train

Hi, I'm trying to run your code from source only train but there is no "list" folder in the dataset directory.

gta5: {
        data_dir: '/media/NAS/nas_187/datasets/gta/',
        data_list: './dataset/list/gta5_list.txt',
        input_size: [1280, 720]
        }
synthia: {
        data_dir: '/home/guangrui/data/synthia/',
        data_list: './dataset/list/synthia_list.txt',
        input_size: [1280, 760]
        }
cityscapes: {
        data_dir: '/media/NAS/nas_187/datasets/synthia',
        data_list: './dataset/list/cityscapes_train.txt',
        input_size: [1024, 512]
        }

Could you please add the missing files?

Also, there is a line trying to add nonexistent files in model/__init__.py

thres in gene_thres

A small question!

Your ccm_trainer.py

159 index = int(cls_total * prop)
160 cls_thres = cls_prob[-index]
161 cls_thres2 = cls_prob[index]
162 thres[k] = cls_thres

For what consideration, you set your thres be the value of the last ten percent of the probability value?

last bacause of (-index), ten percent because of (prop=0.1)

Baseline_model

Hello, thank you for offering nice repository.
I wonder whether you can additionally offer code of your baseline. (Self-training only)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.