File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed
Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 77---
88
99## Training
10+ ```
11+ For PyTorch versions >= 1.10, please replace `python -m torch.distributed.launch` in the commands below with `torchrun`.
12+ ```
1013
1114### 👾 Stage I - VQGAN
1215- Training VQGAN:
13- > python -m torch.distributed.launch --nproc_per_node=8 --master_port=4321 basicsr/train.py -opt options/VQGAN_512_ds32_nearest_stage1.yml --launcher pytorch
16+ > python -m torch.distributed.launch --nproc_per_node=gpu_num --master_port=4321 basicsr/train.py -opt options/VQGAN_512_ds32_nearest_stage1.yml --launcher pytorch
1417
1518- After VQGAN training, you can pre-calculate code sequence for the training dataset to speed up the later training stages:
1619 > python scripts/generate_latent_gt.py
1922
2023### 🚀 Stage II - CodeFormer (w=0)
2124- Training Code Sequence Prediction Module:
22- > python -m torch.distributed.launch --nproc_per_node=8 --master_port=4322 basicsr/train.py -opt options/CodeFormer_stage2.yml --launcher pytorch
25+ > python -m torch.distributed.launch --nproc_per_node=gpu_num --master_port=4322 basicsr/train.py -opt options/CodeFormer_stage2.yml --launcher pytorch
2326
2427- Pre-trained CodeFormer of stage II (` codeformer_stage2.pth ` ) can be found in the folder of Releases v0.1.0: https://github.com/sczhou/CodeFormer/releases/tag/v0.1.0
2528
2629### 🛸 Stage III - CodeFormer (w=1)
2730- Training Controllable Module:
28- > python -m torch.distributed.launch --nproc_per_node=8 --master_port=4323 basicsr/train.py -opt options/CodeFormer_stage3.yml --launcher pytorch
31+ > python -m torch.distributed.launch --nproc_per_node=gpu_num --master_port=4323 basicsr/train.py -opt options/CodeFormer_stage3.yml --launcher pytorch
2932
3033- Pre-trained CodeFormer (` codeformer.pth ` ) can be found in the folder of Releases v0.1.0: https://github.com/sczhou/CodeFormer/releases/tag/v0.1.0
3134
Original file line number Diff line number Diff line change 77---
88
99## 训练
10+ ```
11+ 对于PyTorch版本 >= 1.10, 请将下面命令中的`python -m torch.distributed.launch`替换为`torchrun`.
12+ ```
1013
1114### 👾 阶段 I - VQGAN
1215- 训练VQGAN:
13- > python -m torch.distributed.launch --nproc_per_node=8 --master_port=4321 basicsr/train.py -opt options/VQGAN_512_ds32_nearest_stage1.yml --launcher pytorch
16+ > python -m torch.distributed.launch --nproc_per_node=gpu_num --master_port=4321 basicsr/train.py -opt options/VQGAN_512_ds32_nearest_stage1.yml --launcher pytorch
1417
1518- 训练完VQGAN后,可以通过下面代码预先获得训练数据集的密码本序列,从而加速后面阶段的训练过程:
1619 > python scripts/generate_latent_gt.py
1922
2023### 🚀 阶段 II - CodeFormer (w=0)
2124- 训练密码本训练预测模块:
22- > python -m torch.distributed.launch --nproc_per_node=8 --master_port=4322 basicsr/train.py -opt options/CodeFormer_stage2.yml --launcher pytorch
25+ > python -m torch.distributed.launch --nproc_per_node=gpu_num --master_port=4322 basicsr/train.py -opt options/CodeFormer_stage2.yml --launcher pytorch
2326
2427- 预训练CodeFormer第二阶段模型 (` codeformer_stage2.pth ` )可以在Releases v0.1.0文档里下载: https://github.com/sczhou/CodeFormer/releases/tag/v0.1.0
2528
2629### 🛸 阶段 III - CodeFormer (w=1)
2730- 训练可调模块:
28- > python -m torch.distributed.launch --nproc_per_node=8 --master_port=4323 basicsr/train.py -opt options/CodeFormer_stage3.yml --launcher pytorch
31+ > python -m torch.distributed.launch --nproc_per_node=gpu_num --master_port=4323 basicsr/train.py -opt options/CodeFormer_stage3.yml --launcher pytorch
2932
3033- 预训练CodeFormer模型 (` codeformer.pth ` )可以在Releases v0.1.0文档里下载: https://github.com/sczhou/CodeFormer/releases/tag/v0.1.0
3134
Original file line number Diff line number Diff line change 66
77
88def download_pretrained_models (method , file_urls ):
9+ if method == 'CodeFormer_train' :
10+ method = 'CodeFormer'
911 save_path_root = f'./weights/{ method } '
1012 os .makedirs (save_path_root , exist_ok = True )
1113
@@ -26,6 +28,12 @@ def download_pretrained_models(method, file_urls):
2628 'CodeFormer' : {
2729 'codeformer.pth' : 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth'
2830 },
31+ 'CodeFormer_train' : {
32+ 'vqgan_code1024.pth' : 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/vqgan_code1024.pth' ,
33+ 'latent_gt_code1024.pth' : 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/latent_gt_code1024.pth' ,
34+ 'codeformer_stage2.pth' : 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer_stage2.pth' ,
35+ 'codeformer.pth' : 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth'
36+ },
2937 'facelib' : {
3038 # 'yolov5l-face.pth': 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/yolov5l-face.pth',
3139 'detection_Resnet50_Final.pth' : 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/detection_Resnet50_Final.pth' ,
You can’t perform that action at this time.
0 commit comments