Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
Real-ESRGAN_pytorch
Commits
5e83dadf
Commit
5e83dadf
authored
Feb 05, 2024
by
Rayyyyy
Browse files
modify model name in yamls and update README
parent
e7cce7d3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
15 deletions
+26
-15
README.md
README.md
+15
-9
options/finetune_realesrgan_x4plus.yml
options/finetune_realesrgan_x4plus.yml
+2
-2
options/finetune_realesrgan_x4plus_pairdata.yml
options/finetune_realesrgan_x4plus_pairdata.yml
+2
-2
train.sh
train.sh
+7
-2
No files found.
README.md
View file @
5e83dadf
...
@@ -152,12 +152,13 @@ python scripts/generate_meta_info.py --input datasets/DF2K/DF2K_HR, datasets/DF2
...
@@ -152,12 +152,13 @@ python scripts/generate_meta_info.py --input datasets/DF2K/DF2K_HR, datasets/DF2
## 训练
## 训练
### 完整训练
### 完整训练
#### 训练Real-ESRNet
1.
下载预训练模型
[
ESRGAN
](
https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/ESRGAN_SRx4_DF2KOST_official-ff704c30.pth
)
, 将模型放到
`experiments/pretrained_models`
目录下。
1.
下载预训练模型
[
ESRGAN
](
https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/ESRGAN_SRx4_DF2KOST_official-ff704c30.pth
)
, 将模型放到
`experiments/pretrained_models`
目录下。
```
bash
```
bash
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/ESRGAN_SRx4_DF2KOST_official-ff704c30.pth
-P
experiments/pretrained_models
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/ESRGAN_SRx4_DF2KOST_official-ff704c30.pth
-P
experiments/pretrained_models
```
```
2.
相应地修改
选项文件
`options/train_realesrnet_x4plus.yml`
中的内容:
2.
相应地修改
`options/train_realesrnet_x4plus.yml`
中的内容:
```
yml
```
yml
train
:
train
:
name
:
DF2K+OST
name
:
DF2K+OST
...
@@ -168,7 +169,7 @@ train:
...
@@ -168,7 +169,7 @@ train:
type
:
disk
type
:
disk
```
```
如果需要指定预训练路径到其他文件, 请修改
`pretrain_network_g`
参数, 当前默认保存为
`experiments/train_RealESRNetx4plus_1000k_B12G4_fromESRGAN/model/net_g_1000000.pth`
。
如果需要指定预训练路径到其他文件, 请修改
`pretrain_network_g`
参数, 当前默认保存为
`experiments/train_RealESRNetx4plus_1000k_B12G4_fromESRGAN/model
s
/net_g_1000000.pth`
。
3.
如果你想在训练过程中执行验证, 就取消注释这些内容并进行相应的修改:
3.
如果你想在训练过程中执行验证, 就取消注释这些内容并进行相应的修改:
```
yml
```
yml
...
@@ -196,9 +197,13 @@ train:
...
@@ -196,9 +197,13 @@ train:
# test_y_channel: false
# test_y_channel: false
```
```
### 微调训练
#### 训练Real-ESRGAN
1.
Real-ESRNet模型训练完成后,得到
`experiments/train_RealESRNetx4plus_1000k_B12G4_fromESRGAN/models/net_g_1000000.pth`
;
你可以用自己的数据集微调 Real-ESRGAN。一般地, 微调(Fine-Tune)程序可以分为两种类型:
2.
大多数修改与上面列出的类似, 相应地修改文件
`options/train_realesrgan_x4plus.yml`
中的内容. 如果需要指定其他文件的预训练路径, 请修改
`pretrain_network_g`
参数.
### 微调Real-ESRGAN
你可以用自己的数据集微调Real-ESRGAN。一般地, 微调(Fine-Tune)程序可以分为两种类型:
1.
[
动态生成降级图像
](
#动态生成降级图像
)
1.
[
动态生成降级图像
](
#动态生成降级图像
)
2.
[
使用**已配对**的数据
](
#使用已配对的数据
)
2.
[
使用**已配对**的数据
](
#使用已配对的数据
)
...
@@ -262,9 +267,9 @@ python scripts/generate_meta_info_pairdata.py --input datasets/DF2K/DIV2K_train_
...
@@ -262,9 +267,9 @@ python scripts/generate_meta_info_pairdata.py --input datasets/DF2K/DIV2K_train_
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x4plus_netD.pth
-P
experiments/pretrained_models
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x4plus_netD.pth
-P
experiments/pretrained_models
```
```
3.
finetune
3.
微调准备
修改
选项文件
[
options/finetune_realesrgan_x4plus_pairdata.yml
](
options/finetune_realesrgan_x4plus_pairdata.yml
)
, 特别是
`datasets`
部分:
修改
[
options/finetune_realesrgan_x4plus_pairdata.yml
](
options/finetune_realesrgan_x4plus_pairdata.yml
)
中的配置项
, 特别是
`datasets`
部分:
```
yml
```
yml
train
:
train
:
...
@@ -276,9 +281,10 @@ train:
...
@@ -276,9 +281,10 @@ train:
io_backend
:
io_backend
:
type
:
disk
type
:
disk
```
```
### 训练命令
### 训练命令
#### 单机多卡
#### 单机多卡
默认auto_resume模式, 根据完整训练或者微调训练, 修改-opt参数对应的yml文件。当前默认为
完整
训练
默认auto_resume模式, 根据完整训练或者微调训练, 修改-opt参数对应的yml文件。当前默认为
微调
训练
```
bash
```
bash
bash train.sh
bash train.sh
```
```
...
@@ -286,14 +292,14 @@ bash train.sh
...
@@ -286,14 +292,14 @@ bash train.sh
#### 多机多卡
#### 多机多卡
使用多节点的情况下,需要将使用节点写入hostfile文件, 多节点每个节点一行, 例如: c1xxxxxx slots=4。
使用多节点的情况下,需要将使用节点写入hostfile文件, 多节点每个节点一行, 例如: c1xxxxxx slots=4。
默认auto_resume模式,
如需训练别的yaml,
请修改
`$REAL-ESRGAN_ROOT/single_process.sh`
中CONFIG参数。
默认auto_resume模式,
根据完整训练或者微调训练,
请修改
`$REAL-ESRGAN_ROOT/single_process.sh`
中CONFIG参数。
```
bash
```
bash
bash run_train_multi.sh
bash run_train_multi.sh
```
```
## 推理
## 推理
下载预训练模型
[
RealESRGAN_x4plus.pth
](
https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth
)
, 将其放入 weights文件夹下, 测试结果默认保存在results文件夹下。
下载预训练模型
[
RealESRGAN_x4plus.pth
](
https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth
)
, 将其放入 weights
文件夹下, 测试结果默认保存在results文件夹下。
```
bash
```
bash
# 下载预训练模型
# 下载预训练模型
...
...
options/finetune_realesrgan_x4plus.yml
View file @
5e83dadf
...
@@ -98,8 +98,8 @@ network_d:
...
@@ -98,8 +98,8 @@ network_d:
# path
# path
path
:
path
:
# use the pre-trained Real-ESR
Net
model
# use the pre-trained Real-ESR
GAN
model
pretrain_network_g
:
experiments/pretrained_models/RealESR
Net
_x4plus.pth
pretrain_network_g
:
experiments/pretrained_models/RealESR
GAN
_x4plus.pth
param_key_g
:
params_ema
param_key_g
:
params_ema
strict_load_g
:
true
strict_load_g
:
true
pretrain_network_d
:
experiments/pretrained_models/RealESRGAN_x4plus_netD.pth
pretrain_network_d
:
experiments/pretrained_models/RealESRGAN_x4plus_netD.pth
...
...
options/finetune_realesrgan_x4plus_pairdata.yml
View file @
5e83dadf
...
@@ -60,8 +60,8 @@ network_d:
...
@@ -60,8 +60,8 @@ network_d:
# path
# path
path
:
path
:
# use the pre-trained Real-ESR
Net
model
# use the pre-trained Real-ESR
GAN
model
pretrain_network_g
:
experiments/pretrained_models/RealESR
Net
_x4plus.pth
pretrain_network_g
:
experiments/pretrained_models/RealESR
GAN
_x4plus.pth
param_key_g
:
params_ema
param_key_g
:
params_ema
strict_load_g
:
true
strict_load_g
:
true
pretrain_network_d
:
experiments/pretrained_models/RealESRGAN_x4plus_netD.pth
pretrain_network_d
:
experiments/pretrained_models/RealESRGAN_x4plus_netD.pth
...
...
train.sh
View file @
5e83dadf
...
@@ -4,10 +4,15 @@ export HSA_FORCE_FINE_GRAIN_PCIE=1
...
@@ -4,10 +4,15 @@ export HSA_FORCE_FINE_GRAIN_PCIE=1
export
USE_MIOPEN_BATCHNORM
=
1
export
USE_MIOPEN_BATCHNORM
=
1
echo
"Training start ..."
echo
"Training start ..."
## train multi
## Train
## Train Real-ESRNet
# python -m torch.distributed.launch --nproc_per_node=4 --master_port=4321 realesrgan/train.py -opt options/train_realesrnet_x4plus.yml --launcher pytorch --auto_resume
# python -m torch.distributed.launch --nproc_per_node=4 --master_port=4321 realesrgan/train.py -opt options/train_realesrnet_x4plus.yml --launcher pytorch --auto_resume
##
train
single
## single
# python realesrgan/train.py -opt options/train_realesrnet_x4plus.yml --auto_resume
# python realesrgan/train.py -opt options/train_realesrnet_x4plus.yml --auto_resume
## Train Real-ESRGAN
# python -m torch.distributed.launch --nproc_per_node=4 --master_port=4321 realesrgan/train.py -opt options/train_realesrgan_x4plus.yml --launcher pytorch --auto_resume
## single
# python realesrgan/train.py -opt options/train_realesrgan_x4plus.yml --debug
## finetune
## finetune
python
-m
torch.distributed.launch
--nproc_per_node
=
4
--master_port
=
4321 realesrgan/train.py
-opt
options/finetune_realesrgan_x4plus.yml
--launcher
pytorch
--auto_resume
python
-m
torch.distributed.launch
--nproc_per_node
=
4
--master_port
=
4321 realesrgan/train.py
-opt
options/finetune_realesrgan_x4plus.yml
--launcher
pytorch
--auto_resume
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment