Skip to content

Commit

Permalink
Merge pull request #1 from LielinJiang/init-commit
Browse files Browse the repository at this point in the history
Add cyclegan and pixel2pixel model
  • Loading branch information
qingqing01 committed Jul 3, 2020
2 parents 2255468 + 2e09147 commit d700d09
Show file tree
Hide file tree
Showing 42 changed files with 2,848 additions and 1 deletion.
103 changes: 103 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# PaddleGAN
# PaddleGAN

still under development!!

## Train
```
python -u tools/main.py --config-file configs/cyclegan-cityscapes.yaml
```

continue train from last checkpoint
```
python -u tools/main.py --config-file configs/cyclegan-cityscapes.yaml --resume your_checkpoint_path
```

multiple gpus train:
```
CUDA_VISIBLE_DEVICES=0,1 python -m paddle.distributed.launch tools/main.py --config-file configs/pix2pix-cityscapes.yaml
```

## Evaluate
```
python tools/main.py --config-file configs/cyclegan-cityscapes.yaml --evaluate-only --load your_weight_path
```
74 changes: 74 additions & 0 deletions configs/cyclegan-cityscapes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
epochs: 200
isTrain: True
output_dir: output_dir
lambda_A: 10.0
lambda_B: 10.0
lambda_identity: 0.5

model:
name: CycleGANModel
defaults: &defaults
norm_type: instance
input_nc: 3
generator:
name: ResnetGenerator
output_nc: 3
n_blocks: 9
ngf: 64
use_dropout: False
<<: *defaults
discriminator:
name: NLayerDiscriminator
ndf: 64
n_layers: 3
<<: *defaults
gan_mode: lsgan

dataset:
train:
name: UnalignedDataset
dataroot: data/cityscapes
phase: train
max_dataset_size: inf
direction: AtoB
input_nc: 3
output_nc: 3
serial_batches: False
pool_size: 50
transform:
load_size: 286
crop_size: 256
preprocess: resize_and_crop
no_flip: False
test:
name: SingleDataset
dataroot: data/cityscapes/testB
max_dataset_size: inf
direction: BtoA
input_nc: 3
output_nc: 3
serial_batches: False
pool_size: 50
transform:
load_size: 256
crop_size: 256
preprocess: resize_and_crop
no_flip: True


optimizer:
name: Adam
beta1: 0.5
lr_scheduler:
name: linear
learning_rate: 0.0002
start_epoch: 100
decay_epochs: 100

log_config:
interval: 100
visiual_interval: 500

snapshot_config:
interval: 5

74 changes: 74 additions & 0 deletions configs/cyclegan-horse2zebra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
epochs: 200
isTrain: True
output_dir: output_dir
lambda_A: 10.0
lambda_B: 10.0
lambda_identity: 0.5

model:
name: CycleGANModel
defaults: &defaults
norm_type: instance
input_nc: 3
generator:
name: ResnetGenerator
output_nc: 3
n_blocks: 9
ngf: 64
use_dropout: False
<<: *defaults
discriminator:
name: NLayerDiscriminator
ndf: 64
n_layers: 3
<<: *defaults
gan_mode: lsgan

dataset:
train:
name: UnalignedDataset
dataroot: data/horse2zebra
phase: train
max_dataset_size: inf
direction: AtoB
input_nc: 3
output_nc: 3
serial_batches: False
pool_size: 50
transform:
load_size: 286
crop_size: 256
preprocess: resize_and_crop
no_flip: False
test:
name: SingleDataset
dataroot: data/horse2zebra/testA
max_dataset_size: inf
direction: AtoB
input_nc: 3
output_nc: 3
serial_batches: False
pool_size: 50
transform:
load_size: 256
crop_size: 256
preprocess: resize_and_crop
no_flip: True


optimizer:
name: Adam
beta1: 0.5
lr_scheduler:
name: linear
learning_rate: 0.0002
start_epoch: 100
decay_epochs: 100

log_config:
interval: 100
visiual_interval: 500

snapshot_config:
interval: 5

71 changes: 71 additions & 0 deletions configs/pix2pix-cityscapes-2gpus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
epochs: 200
isTrain: True
output_dir: output_dir
lambda_L1: 100

model:
name: Pix2PixModel
generator:
name: UnetGenerator
norm_type: batch
input_nc: 3
output_nc: 3
num_downs: 8 #unet256
ngf: 64
use_dropout: False
discriminator:
name: NLayerDiscriminator
ndf: 64
n_layers: 3
input_nc: 6
norm_type: batch
gan_mode: vanilla

dataset:
train:
name: AlignedDataset
dataroot: data/cityscapes
phase: train
max_dataset_size: inf
direction: BtoA
input_nc: 3
output_nc: 3
serial_batches: False
pool_size: 0
transform:
load_size: 286
crop_size: 256
preprocess: resize_and_crop
no_flip: False
test:
name: AlignedDataset
dataroot: data/cityscapes/
phase: test
max_dataset_size: inf
direction: BtoA
input_nc: 3
output_nc: 3
serial_batches: True
pool_size: 50
transform:
load_size: 256
crop_size: 256
preprocess: resize_and_crop
no_flip: True

optimizer:
name: Adam
beta1: 0.5
lr_scheduler:
name: linear
learning_rate: 0.0004
start_epoch: 100
decay_epochs: 100

log_config:
interval: 100
visiual_interval: 500

snapshot_config:
interval: 5

Loading

0 comments on commit d700d09

Please sign in to comment.