Commit 5e83dadf authored by Rayyyyy's avatar Rayyyyy
Browse files

modify model name in yamls and update README

parent e7cce7d3
......@@ -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`目录下。
```bash
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
train:
name: DF2K+OST
......@@ -168,7 +169,7 @@ train:
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/models/net_g_1000000.pth`
3. 如果你想在训练过程中执行验证, 就取消注释这些内容并进行相应的修改:
```yml
......@@ -196,9 +197,13 @@ train:
# 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. [动态生成降级图像](#动态生成降级图像)
2. [使用**已配对**的数据](#使用已配对的数据)
......@@ -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
```
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
train:
......@@ -276,9 +281,10 @@ train:
io_backend:
type: disk
```
### 训练命令
#### 单机多卡
默认auto_resume模式, 根据完整训练或者微调训练, 修改-opt参数对应的yml文件。当前默认为完整训练
默认auto_resume模式, 根据完整训练或者微调训练, 修改-opt参数对应的yml文件。当前默认为微调训练
```bash
bash train.sh
```
......@@ -286,14 +292,14 @@ bash train.sh
#### 多机多卡
使用多节点的情况下,需要将使用节点写入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 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
# 下载预训练模型
......
......@@ -98,8 +98,8 @@ network_d:
# path
path:
# use the pre-trained Real-ESRNet model
pretrain_network_g: experiments/pretrained_models/RealESRNet_x4plus.pth
# use the pre-trained Real-ESRGAN model
pretrain_network_g: experiments/pretrained_models/RealESRGAN_x4plus.pth
param_key_g: params_ema
strict_load_g: true
pretrain_network_d: experiments/pretrained_models/RealESRGAN_x4plus_netD.pth
......
......@@ -60,8 +60,8 @@ network_d:
# path
path:
# use the pre-trained Real-ESRNet model
pretrain_network_g: experiments/pretrained_models/RealESRNet_x4plus.pth
# use the pre-trained Real-ESRGAN model
pretrain_network_g: experiments/pretrained_models/RealESRGAN_x4plus.pth
param_key_g: params_ema
strict_load_g: true
pretrain_network_d: experiments/pretrained_models/RealESRGAN_x4plus_netD.pth
......
......@@ -4,10 +4,15 @@ export HSA_FORCE_FINE_GRAIN_PCIE=1
export USE_MIOPEN_BATCHNORM=1
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
## train single
## single
# 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
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment