forked from PaddlePaddle/Paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine codes and docs (PaddlePaddle#61)
* refine codes docs
- Loading branch information
1 parent
b2cc92a
commit 100edd8
Showing
20 changed files
with
641 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
import argparse | ||
|
||
from ppgan.utils.download import get_path_from_url | ||
|
||
CYCLEGAN_URL_ROOT = 'https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/' | ||
|
||
parser = argparse.ArgumentParser(description='download datasets') | ||
parser.add_argument('--name', | ||
type=str, | ||
required=True, | ||
help='dataset name, \ | ||
support dataset name: apple2orange, summer2winter_yosemite, \ | ||
horse2zebra, monet2photo, cezanne2photo, ukiyoe2photo, \ | ||
vangogh2photo, maps, cityscapes, facades, iphone2dslr_flower, \ | ||
ae_photos, cityscapes') | ||
|
||
if __name__ == "__main__": | ||
args = parser.parse_args() | ||
|
||
data_url = CYCLEGAN_URL_ROOT + args.name + '.zip' | ||
|
||
if args.name == 'cityscapes': | ||
data_url = 'https://paddlegan.bj.bcebos.com/datasets/cityscapes.zip' | ||
|
||
path = get_path_from_url(data_url) | ||
|
||
dst = os.path.join('data', args.name) | ||
print('symlink {} to {}'.format(path, dst)) | ||
os.symlink(path, dst) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os | ||
import argparse | ||
|
||
from ppgan.utils.download import get_path_from_url | ||
|
||
PIX2PIX_URL_ROOT = 'http://efrosgans.eecs.berkeley.edu/pix2pix/datasets/' | ||
|
||
parser = argparse.ArgumentParser(description='download datasets') | ||
parser.add_argument('--name', | ||
type=str, | ||
required=True, | ||
help='dataset name, \ | ||
support dataset name: cityscapes, night2day, edges2handbags, \ | ||
edges2shoes, facades, maps') | ||
|
||
if __name__ == "__main__": | ||
args = parser.parse_args() | ||
|
||
data_url = PIX2PIX_URL_ROOT + args.name + '.tar.gz' | ||
|
||
path = get_path_from_url(data_url) | ||
|
||
dst = os.path.join('data', args.name) | ||
print('symlink {} to {}'.format(path, dst)) | ||
os.symlink(path, dst) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,71 @@ | ||
|
||
## 快速开始使用PaddleGAN | ||
|
||
注意: | ||
* 开始使用PaddleGAN前请确保已经阅读过[安装文档](./install.md),并根据[数据准备文档](./data_prepare.md)准备好数据集。 | ||
* 以下教程以CycleGAN模型在Cityscapes数据集上的训练预测作为示例。 | ||
|
||
|
||
### 训练 | ||
|
||
#### 单卡训练 | ||
``` | ||
python -u tools/main.py --config-file configs/cyclegan_cityscapes.yaml | ||
``` | ||
#### 参数 | ||
|
||
continue train from last checkpoint | ||
- `--config-file (str)`: 配置文件的路径。 | ||
|
||
输出的日志,权重,可视化结果会默认保存在```./output_dir```中,可以通过配置文件中的```output_dir```参数修改: | ||
``` | ||
output_dir: output_dir | ||
``` | ||
|
||
保存的文件夹会根据模型名字和时间戳自动生成一个新目录,目录示例如下: | ||
``` | ||
output_dir | ||
└── CycleGANModel-2020-10-29-09-21 | ||
├── epoch_1_checkpoint.pkl | ||
├── log.txt | ||
└── visual_train | ||
├── epoch001_fake_A.png | ||
├── epoch001_fake_B.png | ||
├── epoch001_idt_A.png | ||
├── epoch001_idt_B.png | ||
├── epoch001_real_A.png | ||
├── epoch001_real_B.png | ||
├── epoch001_rec_A.png | ||
├── epoch001_rec_B.png | ||
├── epoch002_fake_A.png | ||
├── epoch002_fake_B.png | ||
├── epoch002_idt_A.png | ||
├── epoch002_idt_B.png | ||
├── epoch002_real_A.png | ||
├── epoch002_real_B.png | ||
├── epoch002_rec_A.png | ||
└── epoch002_rec_B.png | ||
``` | ||
|
||
#### 恢复训练 | ||
|
||
训练过程中默认会保存上一个epoch的checkpoint,方便恢复训练 | ||
``` | ||
python -u tools/main.py --config-file configs/cyclegan_cityscapes.yaml --resume your_checkpoint_path | ||
``` | ||
#### 参数 | ||
|
||
multiple gpus train: | ||
- `--resume (str)`: 用来恢复训练的checkpoint路径。 | ||
|
||
#### 多卡训练: | ||
``` | ||
CUDA_VISIBLE_DEVICES=0,1 python -m paddle.distributed.launch tools/main.py --config-file configs/pix2pix_cityscapes.yaml | ||
CUDA_VISIBLE_DEVICES=0,1 python -m paddle.distributed.launch tools/main.py --config-file configs/cyclegan_cityscapes.yaml | ||
``` | ||
|
||
### 预测 | ||
``` | ||
python tools/main.py --config-file configs/cyclegan_cityscapes.yaml --evaluate-only --load your_weight_path | ||
``` | ||
|
||
#### 参数 | ||
- `--evaluate-only`: 是否仅进行预测。 | ||
- `--load (str)`: 训练好的权重路径。 |
Oops, something went wrong.