Spaces:
Runtime error
Runtime error
Commit
·
68fdbb1
1
Parent(s):
a75e7ae
update training documents.
Browse files- docs/train.md +6 -3
- docs/train_CN.md +6 -3
- scripts/download_pretrained_models.py +8 -0
docs/train.md
CHANGED
@@ -7,10 +7,13 @@
|
|
7 |
---
|
8 |
|
9 |
## Training
|
|
|
|
|
|
|
10 |
|
11 |
### 👾 Stage I - VQGAN
|
12 |
- Training VQGAN:
|
13 |
-
> python -m torch.distributed.launch --nproc_per_node=
|
14 |
|
15 |
- After VQGAN training, you can pre-calculate code sequence for the training dataset to speed up the later training stages:
|
16 |
> python scripts/generate_latent_gt.py
|
@@ -19,13 +22,13 @@
|
|
19 |
|
20 |
### 🚀 Stage II - CodeFormer (w=0)
|
21 |
- Training Code Sequence Prediction Module:
|
22 |
-
> python -m torch.distributed.launch --nproc_per_node=
|
23 |
|
24 |
- 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
|
25 |
|
26 |
### 🛸 Stage III - CodeFormer (w=1)
|
27 |
- Training Controllable Module:
|
28 |
-
> python -m torch.distributed.launch --nproc_per_node=
|
29 |
|
30 |
- 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
|
31 |
|
|
|
7 |
---
|
8 |
|
9 |
## Training
|
10 |
+
```
|
11 |
+
For PyTorch versions >= 1.10, please replace `python -m torch.distributed.launch` in the commands below with `torchrun`.
|
12 |
+
```
|
13 |
|
14 |
### 👾 Stage I - VQGAN
|
15 |
- Training VQGAN:
|
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
|
17 |
|
18 |
- After VQGAN training, you can pre-calculate code sequence for the training dataset to speed up the later training stages:
|
19 |
> python scripts/generate_latent_gt.py
|
|
|
22 |
|
23 |
### 🚀 Stage II - CodeFormer (w=0)
|
24 |
- Training Code Sequence Prediction Module:
|
25 |
+
> python -m torch.distributed.launch --nproc_per_node=gpu_num --master_port=4322 basicsr/train.py -opt options/CodeFormer_stage2.yml --launcher pytorch
|
26 |
|
27 |
- 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
|
28 |
|
29 |
### 🛸 Stage III - CodeFormer (w=1)
|
30 |
- Training Controllable Module:
|
31 |
+
> python -m torch.distributed.launch --nproc_per_node=gpu_num --master_port=4323 basicsr/train.py -opt options/CodeFormer_stage3.yml --launcher pytorch
|
32 |
|
33 |
- 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
|
34 |
|
docs/train_CN.md
CHANGED
@@ -7,10 +7,13 @@
|
|
7 |
---
|
8 |
|
9 |
## 训练
|
|
|
|
|
|
|
10 |
|
11 |
### 👾 阶段 I - VQGAN
|
12 |
- 训练VQGAN:
|
13 |
-
> python -m torch.distributed.launch --nproc_per_node=
|
14 |
|
15 |
- 训练完VQGAN后,可以通过下面代码预先获得训练数据集的密码本序列,从而加速后面阶段的训练过程:
|
16 |
> python scripts/generate_latent_gt.py
|
@@ -19,13 +22,13 @@
|
|
19 |
|
20 |
### 🚀 阶段 II - CodeFormer (w=0)
|
21 |
- 训练密码本训练预测模块:
|
22 |
-
> python -m torch.distributed.launch --nproc_per_node=
|
23 |
|
24 |
- 预训练CodeFormer第二阶段模型 (`codeformer_stage2.pth`)可以在Releases v0.1.0文档里下载: https://github.com/sczhou/CodeFormer/releases/tag/v0.1.0
|
25 |
|
26 |
### 🛸 阶段 III - CodeFormer (w=1)
|
27 |
- 训练可调模块:
|
28 |
-
> python -m torch.distributed.launch --nproc_per_node=
|
29 |
|
30 |
- 预训练CodeFormer模型 (`codeformer.pth`)可以在Releases v0.1.0文档里下载: https://github.com/sczhou/CodeFormer/releases/tag/v0.1.0
|
31 |
|
|
|
7 |
---
|
8 |
|
9 |
## 训练
|
10 |
+
```
|
11 |
+
对于PyTorch版本 >= 1.10, 请将下面命令中的`python -m torch.distributed.launch`替换为`torchrun`.
|
12 |
+
```
|
13 |
|
14 |
### 👾 阶段 I - VQGAN
|
15 |
- 训练VQGAN:
|
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
|
17 |
|
18 |
- 训练完VQGAN后,可以通过下面代码预先获得训练数据集的密码本序列,从而加速后面阶段的训练过程:
|
19 |
> python scripts/generate_latent_gt.py
|
|
|
22 |
|
23 |
### 🚀 阶段 II - CodeFormer (w=0)
|
24 |
- 训练密码本训练预测模块:
|
25 |
+
> python -m torch.distributed.launch --nproc_per_node=gpu_num --master_port=4322 basicsr/train.py -opt options/CodeFormer_stage2.yml --launcher pytorch
|
26 |
|
27 |
- 预训练CodeFormer第二阶段模型 (`codeformer_stage2.pth`)可以在Releases v0.1.0文档里下载: https://github.com/sczhou/CodeFormer/releases/tag/v0.1.0
|
28 |
|
29 |
### 🛸 阶段 III - CodeFormer (w=1)
|
30 |
- 训练可调模块:
|
31 |
+
> python -m torch.distributed.launch --nproc_per_node=gpu_num --master_port=4323 basicsr/train.py -opt options/CodeFormer_stage3.yml --launcher pytorch
|
32 |
|
33 |
- 预训练CodeFormer模型 (`codeformer.pth`)可以在Releases v0.1.0文档里下载: https://github.com/sczhou/CodeFormer/releases/tag/v0.1.0
|
34 |
|
scripts/download_pretrained_models.py
CHANGED
@@ -6,6 +6,8 @@ from basicsr.utils.download_util import load_file_from_url
|
|
6 |
|
7 |
|
8 |
def download_pretrained_models(method, file_urls):
|
|
|
|
|
9 |
save_path_root = f'./weights/{method}'
|
10 |
os.makedirs(save_path_root, exist_ok=True)
|
11 |
|
@@ -26,6 +28,12 @@ if __name__ == '__main__':
|
|
26 |
'CodeFormer': {
|
27 |
'codeformer.pth': 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth'
|
28 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
'facelib': {
|
30 |
# 'yolov5l-face.pth': 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/yolov5l-face.pth',
|
31 |
'detection_Resnet50_Final.pth': 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/detection_Resnet50_Final.pth',
|
|
|
6 |
|
7 |
|
8 |
def download_pretrained_models(method, file_urls):
|
9 |
+
if method == 'CodeFormer_train':
|
10 |
+
method = 'CodeFormer'
|
11 |
save_path_root = f'./weights/{method}'
|
12 |
os.makedirs(save_path_root, exist_ok=True)
|
13 |
|
|
|
28 |
'CodeFormer': {
|
29 |
'codeformer.pth': 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth'
|
30 |
},
|
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 |
+
},
|
37 |
'facelib': {
|
38 |
# 'yolov5l-face.pth': 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/yolov5l-face.pth',
|
39 |
'detection_Resnet50_Final.pth': 'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/detection_Resnet50_Final.pth',
|