Skip to content

Commit

Permalink
Init commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
xhan233 committed Jun 10, 2022
0 parents commit 10c3bfa
Show file tree
Hide file tree
Showing 96 changed files with 3,881 additions and 0 deletions.
98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Semi-Supervised Domain Generalization in Real World: New Benchmark and Strong Baseline

[paper](https://arxiv.org/pdf/2111.10221.pdf)

## Requirements

- numpy==1.19.2
- Pillow==9.1.1
- PyYAML==6.0
- scikit_learn==1.1.1
- six==1.15.0
- torch==1.7.1
- torchvision==0.8.2

## Installation

```
git clone https://github.com/MetaVisionLab/SSDG.git
cd SSDG
pip install -r requirements.txt
```

## Data Preparation

You can download the dataset to the folder SSDG/data,which include three folders representing three datasets in our paper

**PACS**

Download the dataset [PACS](https://drive.google.com/file/d/1m4X4fROCCXMO0lRLrr6Zz9Vb3974NWhE/view) to data/pacs and unzip it(this dataset link directly provides images and splits)

File structure:

```
pacs/
|–– images/
|–– splits/
```

**Digits-DG**

Since we provide the dataset splits in this repo,you just need to download the dataset [Digits-DG](https://drive.google.com/file/d/15V7EsHfCcfbKgsDmzQKj_DfXt_XYp_P7/view) to data/digits_dg/images and unzip it

File structure:

```
digits_dg/
|–– images/
|–– splits/
```

**Office-Home-DG**

Since we provide the dataset splits in this repo,you just need to download the dataset [Digits-DG](https://drive.google.com/file/d/15V7EsHfCcfbKgsDmzQKj_DfXt_XYp_P7/view) to data/digits_dg/images and unzip it

File structure:

```
office_home_dg/
|–– images/
|–– splits/
```

## Training

```
sh pacs.sh #train pacs
sh digits.sh #train digits_dg
sh officeHome.sh #train office_home_dg
```

# Validation

We evaluate our method on all the SSDG tasks for each dataset and report the average accuracy.For each task(for example A2C),we report its average accuracy on last 5 epoch.

```
cd tools/
python parse_test_res_single.py log/UDAG_A2C.log --test-log
```

# Citation

Please cite our paper:

```
@article{lin2021ssdg,
title={Semi-Supervised Domain Generalization in Real World: New Benchmark and Strong Baseline},
author={Lin, Luojun and Xie, Han and Yang, Zhifeng and Sun, Zhishu and Liu, Wenxi and Yu, Yuanlong and Chen, Weijie and Yang, Shicai and Xie, Di},
journal={arXiv preprint arXiv:2111.10221},
year={2021}
}
```
# Contact us

For any questions, please feel free to contact [Han Xie](mailto:[email protected]) or Dr. [Luojun Lin](mailto:[email protected]).

# Copyright

This code is free to the academic community for research purpose only. For commercial purpose usage, please contact Dr. [Luojun Lin](mailto:[email protected]).
32 changes: 32 additions & 0 deletions config/A2C.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
data_transforms:
input_size: 224

trainer:
n_step_f: 4 # MCD N_STEP_F
batch_size: 128
# max_epochs: 200
num_workers: 4
save_model_addr: 'checkpoints/A2C'
forget_rate: 0.5

optimizer:
name: 'SGD'
params:
lr: 0.001
momentum: 0.9
weight_decay: 0.0005

data:
type: 'pacs'
class_number: 7
root: 'data/pacs'
source_domain_x: 'art_painting'
source_domain_u_1: 'sketch'
source_domain_u_2: 'photo'
target_domain: 'cartoon'

log:
save_addr: 'log'
save_name: 'UDAG_A2C'

ratio: 0.4 # a ratio to split samples into clean set and noisy set
32 changes: 32 additions & 0 deletions config/A2P.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
data_transforms:
input_size: 224

trainer:
n_step_f: 4 # MCD N_STEP_F
batch_size: 128
# max_epochs: 200
num_workers: 4
save_model_addr: 'checkpoints/A2P'
forget_rate: 0.5

optimizer:
name: 'SGD'
params:
lr: 0.001
momentum: 0.9
weight_decay: 0.0005

data:
type: 'pacs'
class_number: 7
root: 'data/pacs'
source_domain_x: 'art_painting'
source_domain_u_1: 'sketch'
source_domain_u_2: 'cartoon'
target_domain: 'photo'

log:
save_addr: 'log'
save_name: 'UDAG_A2P'

ratio: 0.4 # a ratio to split samples into clean set and noisy set
32 changes: 32 additions & 0 deletions config/A2S.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
data_transforms:
input_size: 224

trainer:
n_step_f: 4 # MCD N_STEP_F
batch_size: 128
# max_epochs: 200
num_workers: 4
save_model_addr: 'checkpoints/A2S'
forget_rate: 0.5

optimizer:
name: 'SGD'
params:
lr: 0.001
momentum: 0.9
weight_decay: 0.0005

data:
type: 'pacs'
class_number: 7
root: 'data/pacs'
source_domain_x: 'art_painting'
source_domain_u_1: 'photo'
source_domain_u_2: 'cartoon'
target_domain: 'sketch'

log:
save_addr: 'log'
save_name: 'UDAG_A2S'

ratio: 0.4 # a ratio to split samples into clean set and noisy set
32 changes: 32 additions & 0 deletions config/C2A.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
data_transforms:
input_size: 224

trainer:
n_step_f: 4 # MCD N_STEP_F
batch_size: 128
# max_epochs: 200
num_workers: 4
save_model_addr: 'checkpoints/C2A'
forget_rate: 0.5

optimizer:
name: 'SGD'
params:
lr: 0.001
momentum: 0.9
weight_decay: 0.0005

data:
type: 'pacs'
class_number: 7
root: 'data/pacs'
source_domain_x: 'cartoon'
source_domain_u_1: 'sketch'
source_domain_u_2: 'photo'
target_domain: 'art_painting'

log:
save_addr: 'log'
save_name: 'UDAG_C2A'

ratio: 0.4 # a ratio to split samples into clean set and noisy set
32 changes: 32 additions & 0 deletions config/C2P.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
data_transforms:
input_size: 224

trainer:
n_step_f: 4 # MCD N_STEP_F
batch_size: 128
# max_epochs: 200
num_workers: 4
save_model_addr: 'checkpoints/C2P'
forget_rate: 0.5

optimizer:
name: 'SGD'
params:
lr: 0.001
momentum: 0.9
weight_decay: 0.0005

data:
type: 'pacs'
class_number: 7
root: 'data/pacs'
source_domain_x: 'cartoon'
source_domain_u_1: 'sketch'
source_domain_u_2: 'art_painting'
target_domain: 'photo'

log:
save_addr: 'log'
save_name: 'UDAG_C2P'

ratio: 0.4 # a ratio to split samples into clean set and noisy set
32 changes: 32 additions & 0 deletions config/C2S.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
data_transforms:
input_size: 224

trainer:
n_step_f: 4 # MCD N_STEP_F
batch_size: 128
# max_epochs: 200
num_workers: 4
save_model_addr: 'checkpoints/C2S'
forget_rate: 0.5

optimizer:
name: 'SGD'
params:
lr: 0.001
momentum: 0.9
weight_decay: 0.0005

data:
type: 'pacs'
class_number: 7
root: 'data/pacs'
source_domain_x: 'cartoon'
source_domain_u_1: 'art_painting'
source_domain_u_2: 'photo'
target_domain: 'sketch'

log:
save_addr: 'log'
save_name: 'UDAG_C2S'

ratio: 0.4 # a ratio to split samples into clean set and noisy set
36 changes: 36 additions & 0 deletions config/P2A.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
data_transforms:
input_size: 224

trainer:
n_step_f: 4 # MCD N_STEP_F
batch_size: 128
# max_epochs: 200
num_workers: 4
save_model_addr: 'checkpoints/P2A'
forget_rate: 0.5

optimizer:
name: 'SGD'
params:
lr: 0.001
momentum: 0.9
weight_decay: 0.0005

data:
type: 'pacs'
class_number: 7
root: 'data/pacs'
source_domain_x: 'photo'
source_domain_u_1: 'sketch'
source_domain_u_2: 'cartoon'
target_domain: 'art_painting'

log:
save_addr: 'log'
save_name: 'UDAG_P2A'

ratio: 0.4 # a ratio to split samples into clean set and noisy set




36 changes: 36 additions & 0 deletions config/P2C.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
data_transforms:
input_size: 224

trainer:
n_step_f: 4 # MCD N_STEP_F
batch_size: 128
# max_epochs: 200
num_workers: 4
save_model_addr: 'checkpoints/P2C'
forget_rate: 0.5

optimizer:
name: 'SGD'
params:
lr: 0.001
momentum: 0.9
weight_decay: 0.0005

data:
type: 'pacs'
class_number: 7
root: 'data/pacs'
source_domain_x: 'photo'
source_domain_u_1: 'sketch'
source_domain_u_2: 'art_painting'
target_domain: 'cartoon'

log:
save_addr: 'log'
save_name: 'UDAG_P2C'

ratio: 0.4 # a ratio to split samples into clean set and noisy set




Loading

0 comments on commit 10c3bfa

Please sign in to comment.