Spaces:
Build error
Build error
Upload 11 files
Browse files- docs/CONTRIBUTING.md +44 -0
- docs/FAQ.md +10 -0
- docs/Training.md +271 -0
- docs/Training_CN.md +271 -0
- docs/anime_comparisons.md +66 -0
- docs/anime_comparisons_CN.md +68 -0
- docs/anime_model.md +68 -0
- docs/anime_video_model.md +136 -0
- docs/feedback.md +11 -0
- docs/model_zoo.md +49 -0
- docs/ncnn_conversion.md +11 -0
docs/CONTRIBUTING.md
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contributing to Real-ESRGAN
|
2 |
+
|
3 |
+
:art: Real-ESRGAN needs your contributions. Any contributions are welcome, such as new features/models/typo fixes/suggestions/maintenance, *etc*. See [CONTRIBUTING.md](docs/CONTRIBUTING.md). All contributors are list [here](README.md#hugs-acknowledgement).
|
4 |
+
|
5 |
+
We like open-source and want to develop practical algorithms for general image restoration. However, individual strength is limited. So, any kinds of contributions are welcome, such as:
|
6 |
+
|
7 |
+
- New features
|
8 |
+
- New models (your fine-tuned models)
|
9 |
+
- Bug fixes
|
10 |
+
- Typo fixes
|
11 |
+
- Suggestions
|
12 |
+
- Maintenance
|
13 |
+
- Documents
|
14 |
+
- *etc*
|
15 |
+
|
16 |
+
## Workflow
|
17 |
+
|
18 |
+
1. Fork and pull the latest Real-ESRGAN repository
|
19 |
+
1. Checkout a new branch (do not use master branch for PRs)
|
20 |
+
1. Commit your changes
|
21 |
+
1. Create a PR
|
22 |
+
|
23 |
+
**Note**:
|
24 |
+
|
25 |
+
1. Please check the code style and linting
|
26 |
+
1. The style configuration is specified in [setup.cfg](setup.cfg)
|
27 |
+
1. If you use VSCode, the settings are configured in [.vscode/settings.json](.vscode/settings.json)
|
28 |
+
1. Strongly recommend using `pre-commit hook`. It will check your code style and linting before your commit.
|
29 |
+
1. In the root path of project folder, run `pre-commit install`
|
30 |
+
1. The pre-commit configuration is listed in [.pre-commit-config.yaml](.pre-commit-config.yaml)
|
31 |
+
1. Better to [open a discussion](https://github.com/xinntao/Real-ESRGAN/discussions) before large changes.
|
32 |
+
1. Welcome to discuss :sunglasses:. I will try my best to join the discussion.
|
33 |
+
|
34 |
+
## TODO List
|
35 |
+
|
36 |
+
:zero: The most straightforward way of improving model performance is to fine-tune on some specific datasets.
|
37 |
+
|
38 |
+
Here are some TODOs:
|
39 |
+
|
40 |
+
- [ ] optimize for human faces
|
41 |
+
- [ ] optimize for texts
|
42 |
+
- [ ] support controllable restoration strength
|
43 |
+
|
44 |
+
:one: There are also [several issues](https://github.com/xinntao/Real-ESRGAN/issues) that require helpers to improve. If you can help, please let me know :smile:
|
docs/FAQ.md
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# FAQ
|
2 |
+
|
3 |
+
1. **Q: How to select models?**<br>
|
4 |
+
A: Please refer to [docs/model_zoo.md](docs/model_zoo.md)
|
5 |
+
|
6 |
+
1. **Q: Can `face_enhance` be used for anime images/animation videos?**<br>
|
7 |
+
A: No, it can only be used for real faces. It is recommended not to use this option for anime images/animation videos to save GPU memory.
|
8 |
+
|
9 |
+
1. **Q: Error "slow_conv2d_cpu" not implemented for 'Half'**<br>
|
10 |
+
A: In order to save GPU memory consumption and speed up inference, Real-ESRGAN uses half precision (fp16) during inference by default. However, some operators for half inference are not implemented in CPU mode. You need to add **`--fp32` option** for the commands. For example, `python inference_realesrgan.py -n RealESRGAN_x4plus.pth -i inputs --fp32`.
|
docs/Training.md
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# :computer: How to Train/Finetune Real-ESRGAN
|
2 |
+
|
3 |
+
- [Train Real-ESRGAN](#train-real-esrgan)
|
4 |
+
- [Overview](#overview)
|
5 |
+
- [Dataset Preparation](#dataset-preparation)
|
6 |
+
- [Train Real-ESRNet](#Train-Real-ESRNet)
|
7 |
+
- [Train Real-ESRGAN](#Train-Real-ESRGAN)
|
8 |
+
- [Finetune Real-ESRGAN on your own dataset](#Finetune-Real-ESRGAN-on-your-own-dataset)
|
9 |
+
- [Generate degraded images on the fly](#Generate-degraded-images-on-the-fly)
|
10 |
+
- [Use paired training data](#use-your-own-paired-data)
|
11 |
+
|
12 |
+
[English](Training.md) **|** [简体中文](Training_CN.md)
|
13 |
+
|
14 |
+
## Train Real-ESRGAN
|
15 |
+
|
16 |
+
### Overview
|
17 |
+
|
18 |
+
The training has been divided into two stages. These two stages have the same data synthesis process and training pipeline, except for the loss functions. Specifically,
|
19 |
+
|
20 |
+
1. We first train Real-ESRNet with L1 loss from the pre-trained model ESRGAN.
|
21 |
+
1. We then use the trained Real-ESRNet model as an initialization of the generator, and train the Real-ESRGAN with a combination of L1 loss, perceptual loss and GAN loss.
|
22 |
+
|
23 |
+
### Dataset Preparation
|
24 |
+
|
25 |
+
We use DF2K (DIV2K and Flickr2K) + OST datasets for our training. Only HR images are required. <br>
|
26 |
+
You can download from :
|
27 |
+
|
28 |
+
1. DIV2K: http://data.vision.ee.ethz.ch/cvl/DIV2K/DIV2K_train_HR.zip
|
29 |
+
2. Flickr2K: https://cv.snu.ac.kr/research/EDSR/Flickr2K.tar
|
30 |
+
3. OST: https://openmmlab.oss-cn-hangzhou.aliyuncs.com/datasets/OST_dataset.zip
|
31 |
+
|
32 |
+
Here are steps for data preparation.
|
33 |
+
|
34 |
+
#### Step 1: [Optional] Generate multi-scale images
|
35 |
+
|
36 |
+
For the DF2K dataset, we use a multi-scale strategy, *i.e.*, we downsample HR images to obtain several Ground-Truth images with different scales. <br>
|
37 |
+
You can use the [scripts/generate_multiscale_DF2K.py](scripts/generate_multiscale_DF2K.py) script to generate multi-scale images. <br>
|
38 |
+
Note that this step can be omitted if you just want to have a fast try.
|
39 |
+
|
40 |
+
```bash
|
41 |
+
python scripts/generate_multiscale_DF2K.py --input datasets/DF2K/DF2K_HR --output datasets/DF2K/DF2K_multiscale
|
42 |
+
```
|
43 |
+
|
44 |
+
#### Step 2: [Optional] Crop to sub-images
|
45 |
+
|
46 |
+
We then crop DF2K images into sub-images for faster IO and processing.<br>
|
47 |
+
This step is optional if your IO is enough or your disk space is limited.
|
48 |
+
|
49 |
+
You can use the [scripts/extract_subimages.py](scripts/extract_subimages.py) script. Here is the example:
|
50 |
+
|
51 |
+
```bash
|
52 |
+
python scripts/extract_subimages.py --input datasets/DF2K/DF2K_multiscale --output datasets/DF2K/DF2K_multiscale_sub --crop_size 400 --step 200
|
53 |
+
```
|
54 |
+
|
55 |
+
#### Step 3: Prepare a txt for meta information
|
56 |
+
|
57 |
+
You need to prepare a txt file containing the image paths. The following are some examples in `meta_info_DF2Kmultiscale+OST_sub.txt` (As different users may have different sub-images partitions, this file is not suitable for your purpose and you need to prepare your own txt file):
|
58 |
+
|
59 |
+
```txt
|
60 |
+
DF2K_HR_sub/000001_s001.png
|
61 |
+
DF2K_HR_sub/000001_s002.png
|
62 |
+
DF2K_HR_sub/000001_s003.png
|
63 |
+
...
|
64 |
+
```
|
65 |
+
|
66 |
+
You can use the [scripts/generate_meta_info.py](scripts/generate_meta_info.py) script to generate the txt file. <br>
|
67 |
+
You can merge several folders into one meta_info txt. Here is the example:
|
68 |
+
|
69 |
+
```bash
|
70 |
+
python scripts/generate_meta_info.py --input datasets/DF2K/DF2K_HR datasets/DF2K/DF2K_multiscale --root datasets/DF2K datasets/DF2K --meta_info datasets/DF2K/meta_info/meta_info_DF2Kmultiscale.txt
|
71 |
+
```
|
72 |
+
|
73 |
+
### Train Real-ESRNet
|
74 |
+
|
75 |
+
1. Download pre-trained model [ESRGAN](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/ESRGAN_SRx4_DF2KOST_official-ff704c30.pth) into `experiments/pretrained_models`.
|
76 |
+
```bash
|
77 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/ESRGAN_SRx4_DF2KOST_official-ff704c30.pth -P experiments/pretrained_models
|
78 |
+
```
|
79 |
+
1. Modify the content in the option file `options/train_realesrnet_x4plus.yml` accordingly:
|
80 |
+
```yml
|
81 |
+
train:
|
82 |
+
name: DF2K+OST
|
83 |
+
type: RealESRGANDataset
|
84 |
+
dataroot_gt: datasets/DF2K # modify to the root path of your folder
|
85 |
+
meta_info: realesrgan/meta_info/meta_info_DF2Kmultiscale+OST_sub.txt # modify to your own generate meta info txt
|
86 |
+
io_backend:
|
87 |
+
type: disk
|
88 |
+
```
|
89 |
+
1. If you want to perform validation during training, uncomment those lines and modify accordingly:
|
90 |
+
```yml
|
91 |
+
# Uncomment these for validation
|
92 |
+
# val:
|
93 |
+
# name: validation
|
94 |
+
# type: PairedImageDataset
|
95 |
+
# dataroot_gt: path_to_gt
|
96 |
+
# dataroot_lq: path_to_lq
|
97 |
+
# io_backend:
|
98 |
+
# type: disk
|
99 |
+
|
100 |
+
...
|
101 |
+
|
102 |
+
# Uncomment these for validation
|
103 |
+
# validation settings
|
104 |
+
# val:
|
105 |
+
# val_freq: !!float 5e3
|
106 |
+
# save_img: True
|
107 |
+
|
108 |
+
# metrics:
|
109 |
+
# psnr: # metric name, can be arbitrary
|
110 |
+
# type: calculate_psnr
|
111 |
+
# crop_border: 4
|
112 |
+
# test_y_channel: false
|
113 |
+
```
|
114 |
+
1. Before the formal training, you may run in the `--debug` mode to see whether everything is OK. We use four GPUs for training:
|
115 |
+
```bash
|
116 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
117 |
+
python -m torch.distributed.launch --nproc_per_node=4 --master_port=4321 realesrgan/train.py -opt options/train_realesrnet_x4plus.yml --launcher pytorch --debug
|
118 |
+
```
|
119 |
+
|
120 |
+
Train with **a single GPU** in the *debug* mode:
|
121 |
+
```bash
|
122 |
+
python realesrgan/train.py -opt options/train_realesrnet_x4plus.yml --debug
|
123 |
+
```
|
124 |
+
1. The formal training. We use four GPUs for training. We use the `--auto_resume` argument to automatically resume the training if necessary.
|
125 |
+
```bash
|
126 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
127 |
+
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
|
128 |
+
```
|
129 |
+
|
130 |
+
Train with **a single GPU**:
|
131 |
+
```bash
|
132 |
+
python realesrgan/train.py -opt options/train_realesrnet_x4plus.yml --auto_resume
|
133 |
+
```
|
134 |
+
|
135 |
+
### Train Real-ESRGAN
|
136 |
+
|
137 |
+
1. After the training of Real-ESRNet, you now have the file `experiments/train_RealESRNetx4plus_1000k_B12G4_fromESRGAN/model/net_g_1000000.pth`. If you need to specify the pre-trained path to other files, modify the `pretrain_network_g` value in the option file `train_realesrgan_x4plus.yml`.
|
138 |
+
1. Modify the option file `train_realesrgan_x4plus.yml` accordingly. Most modifications are similar to those listed above.
|
139 |
+
1. Before the formal training, you may run in the `--debug` mode to see whether everything is OK. We use four GPUs for training:
|
140 |
+
```bash
|
141 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
142 |
+
python -m torch.distributed.launch --nproc_per_node=4 --master_port=4321 realesrgan/train.py -opt options/train_realesrgan_x4plus.yml --launcher pytorch --debug
|
143 |
+
```
|
144 |
+
|
145 |
+
Train with **a single GPU** in the *debug* mode:
|
146 |
+
```bash
|
147 |
+
python realesrgan/train.py -opt options/train_realesrgan_x4plus.yml --debug
|
148 |
+
```
|
149 |
+
1. The formal training. We use four GPUs for training. We use the `--auto_resume` argument to automatically resume the training if necessary.
|
150 |
+
```bash
|
151 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
152 |
+
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
|
153 |
+
```
|
154 |
+
|
155 |
+
Train with **a single GPU**:
|
156 |
+
```bash
|
157 |
+
python realesrgan/train.py -opt options/train_realesrgan_x4plus.yml --auto_resume
|
158 |
+
```
|
159 |
+
|
160 |
+
## Finetune Real-ESRGAN on your own dataset
|
161 |
+
|
162 |
+
You can finetune Real-ESRGAN on your own dataset. Typically, the fine-tuning process can be divided into two cases:
|
163 |
+
|
164 |
+
1. [Generate degraded images on the fly](#Generate-degraded-images-on-the-fly)
|
165 |
+
1. [Use your own **paired** data](#Use-paired-training-data)
|
166 |
+
|
167 |
+
### Generate degraded images on the fly
|
168 |
+
|
169 |
+
Only high-resolution images are required. The low-quality images are generated with the degradation process described in Real-ESRGAN during training.
|
170 |
+
|
171 |
+
**1. Prepare dataset**
|
172 |
+
|
173 |
+
See [this section](#dataset-preparation) for more details.
|
174 |
+
|
175 |
+
**2. Download pre-trained models**
|
176 |
+
|
177 |
+
Download pre-trained models into `experiments/pretrained_models`.
|
178 |
+
|
179 |
+
- *RealESRGAN_x4plus.pth*:
|
180 |
+
```bash
|
181 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P experiments/pretrained_models
|
182 |
+
```
|
183 |
+
|
184 |
+
- *RealESRGAN_x4plus_netD.pth*:
|
185 |
+
```bash
|
186 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x4plus_netD.pth -P experiments/pretrained_models
|
187 |
+
```
|
188 |
+
|
189 |
+
**3. Finetune**
|
190 |
+
|
191 |
+
Modify [options/finetune_realesrgan_x4plus.yml](options/finetune_realesrgan_x4plus.yml) accordingly, especially the `datasets` part:
|
192 |
+
|
193 |
+
```yml
|
194 |
+
train:
|
195 |
+
name: DF2K+OST
|
196 |
+
type: RealESRGANDataset
|
197 |
+
dataroot_gt: datasets/DF2K # modify to the root path of your folder
|
198 |
+
meta_info: realesrgan/meta_info/meta_info_DF2Kmultiscale+OST_sub.txt # modify to your own generate meta info txt
|
199 |
+
io_backend:
|
200 |
+
type: disk
|
201 |
+
```
|
202 |
+
|
203 |
+
We use four GPUs for training. We use the `--auto_resume` argument to automatically resume the training if necessary.
|
204 |
+
|
205 |
+
```bash
|
206 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
207 |
+
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
|
208 |
+
```
|
209 |
+
|
210 |
+
Finetune with **a single GPU**:
|
211 |
+
```bash
|
212 |
+
python realesrgan/train.py -opt options/finetune_realesrgan_x4plus.yml --auto_resume
|
213 |
+
```
|
214 |
+
|
215 |
+
### Use your own paired data
|
216 |
+
|
217 |
+
You can also finetune RealESRGAN with your own paired data. It is more similar to fine-tuning ESRGAN.
|
218 |
+
|
219 |
+
**1. Prepare dataset**
|
220 |
+
|
221 |
+
Assume that you already have two folders:
|
222 |
+
|
223 |
+
- **gt folder** (Ground-truth, high-resolution images): *datasets/DF2K/DIV2K_train_HR_sub*
|
224 |
+
- **lq folder** (Low quality, low-resolution images): *datasets/DF2K/DIV2K_train_LR_bicubic_X4_sub*
|
225 |
+
|
226 |
+
Then, you can prepare the meta_info txt file using the script [scripts/generate_meta_info_pairdata.py](scripts/generate_meta_info_pairdata.py):
|
227 |
+
|
228 |
+
```bash
|
229 |
+
python scripts/generate_meta_info_pairdata.py --input datasets/DF2K/DIV2K_train_HR_sub datasets/DF2K/DIV2K_train_LR_bicubic_X4_sub --meta_info datasets/DF2K/meta_info/meta_info_DIV2K_sub_pair.txt
|
230 |
+
```
|
231 |
+
|
232 |
+
**2. Download pre-trained models**
|
233 |
+
|
234 |
+
Download pre-trained models into `experiments/pretrained_models`.
|
235 |
+
|
236 |
+
- *RealESRGAN_x4plus.pth*
|
237 |
+
```bash
|
238 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P experiments/pretrained_models
|
239 |
+
```
|
240 |
+
|
241 |
+
- *RealESRGAN_x4plus_netD.pth*
|
242 |
+
```bash
|
243 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x4plus_netD.pth -P experiments/pretrained_models
|
244 |
+
```
|
245 |
+
|
246 |
+
**3. Finetune**
|
247 |
+
|
248 |
+
Modify [options/finetune_realesrgan_x4plus_pairdata.yml](options/finetune_realesrgan_x4plus_pairdata.yml) accordingly, especially the `datasets` part:
|
249 |
+
|
250 |
+
```yml
|
251 |
+
train:
|
252 |
+
name: DIV2K
|
253 |
+
type: RealESRGANPairedDataset
|
254 |
+
dataroot_gt: datasets/DF2K # modify to the root path of your folder
|
255 |
+
dataroot_lq: datasets/DF2K # modify to the root path of your folder
|
256 |
+
meta_info: datasets/DF2K/meta_info/meta_info_DIV2K_sub_pair.txt # modify to your own generate meta info txt
|
257 |
+
io_backend:
|
258 |
+
type: disk
|
259 |
+
```
|
260 |
+
|
261 |
+
We use four GPUs for training. We use the `--auto_resume` argument to automatically resume the training if necessary.
|
262 |
+
|
263 |
+
```bash
|
264 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
265 |
+
python -m torch.distributed.launch --nproc_per_node=4 --master_port=4321 realesrgan/train.py -opt options/finetune_realesrgan_x4plus_pairdata.yml --launcher pytorch --auto_resume
|
266 |
+
```
|
267 |
+
|
268 |
+
Finetune with **a single GPU**:
|
269 |
+
```bash
|
270 |
+
python realesrgan/train.py -opt options/finetune_realesrgan_x4plus_pairdata.yml --auto_resume
|
271 |
+
```
|
docs/Training_CN.md
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# :computer: 如何训练/微调 Real-ESRGAN
|
2 |
+
|
3 |
+
- [训练 Real-ESRGAN](#训练-real-esrgan)
|
4 |
+
- [概述](#概述)
|
5 |
+
- [准备数据集](#准备数据集)
|
6 |
+
- [训练 Real-ESRNet 模型](#训练-real-esrnet-模型)
|
7 |
+
- [训练 Real-ESRGAN 模型](#训练-real-esrgan-模型)
|
8 |
+
- [用自己的数据集微调 Real-ESRGAN](#用自己的数据集微调-real-esrgan)
|
9 |
+
- [动态生成降级图像](#动态生成降级图像)
|
10 |
+
- [使用已配对的数据](#使用已配对的数据)
|
11 |
+
|
12 |
+
[English](Training.md) **|** [简体中文](Training_CN.md)
|
13 |
+
|
14 |
+
## 训练 Real-ESRGAN
|
15 |
+
|
16 |
+
### 概述
|
17 |
+
|
18 |
+
训练分为两个步骤。除了 loss 函数外,这两个步骤拥有相同数据合成以及训练的一条龙流程。具体点说:
|
19 |
+
|
20 |
+
1. 首先使用 L1 loss 训练 Real-ESRNet 模型,其中 L1 loss 来自预先训练的 ESRGAN 模型。
|
21 |
+
|
22 |
+
2. 然后我们将 Real-ESRNet 模型作为生成器初始化,结合L1 loss、感知 loss、GAN loss 三者的参数对 Real-ESRGAN 进行训练。
|
23 |
+
|
24 |
+
### 准备数据集
|
25 |
+
|
26 |
+
我们使用 DF2K ( DIV2K 和 Flickr2K ) + OST 数据集进行训练。只需要HR图像!<br>
|
27 |
+
下面是网站链接:
|
28 |
+
1. DIV2K: http://data.vision.ee.ethz.ch/cvl/DIV2K/DIV2K_train_HR.zip
|
29 |
+
2. Flickr2K: https://cv.snu.ac.kr/research/EDSR/Flickr2K.tar
|
30 |
+
3. OST: https://openmmlab.oss-cn-hangzhou.aliyuncs.com/datasets/OST_dataset.zip
|
31 |
+
|
32 |
+
以下是数据的准备步骤。
|
33 |
+
|
34 |
+
#### 第1步:【可选】生成多尺寸图片
|
35 |
+
|
36 |
+
针对 DF2K 数据集,我们使用多尺寸缩放策略,*换言之*,我们对 HR 图像进行下采样,就能获得多尺寸的标准参考(Ground-Truth)图像。 <br>
|
37 |
+
您可以使用这个 [scripts/generate_multiscale_DF2K.py](scripts/generate_multiscale_DF2K.py) 脚本快速生成多尺寸的图像。<br>
|
38 |
+
注意:如果您只想简单试试,那么可以跳过此步骤。
|
39 |
+
|
40 |
+
```bash
|
41 |
+
python scripts/generate_multiscale_DF2K.py --input datasets/DF2K/DF2K_HR --output datasets/DF2K/DF2K_multiscale
|
42 |
+
```
|
43 |
+
|
44 |
+
#### 第2步:【可选】裁切为子图像
|
45 |
+
|
46 |
+
我们可以将 DF2K 图像裁切为子图像,以加快 IO 和处理速度。<br>
|
47 |
+
如果你的 IO 够好或储存空间有限,那么此步骤是可选的。<br>
|
48 |
+
|
49 |
+
您可以使用脚本 [scripts/extract_subimages.py](scripts/extract_subimages.py)。这是使用示例:
|
50 |
+
|
51 |
+
```bash
|
52 |
+
python scripts/extract_subimages.py --input datasets/DF2K/DF2K_multiscale --output datasets/DF2K/DF2K_multiscale_sub --crop_size 400 --step 200
|
53 |
+
```
|
54 |
+
|
55 |
+
#### 第3步:准备元信息 txt
|
56 |
+
|
57 |
+
您需要准备一个包含图像路径的 txt 文件。下面是 `meta_info_DF2Kmultiscale+OST_sub.txt` 中的部分展示(由于各个用户可能有截然不同的子图像划分,这个文件不适合你的需求,你得准备自己的 txt 文件):
|
58 |
+
|
59 |
+
```txt
|
60 |
+
DF2K_HR_sub/000001_s001.png
|
61 |
+
DF2K_HR_sub/000001_s002.png
|
62 |
+
DF2K_HR_sub/000001_s003.png
|
63 |
+
...
|
64 |
+
```
|
65 |
+
|
66 |
+
你可以使用该脚本 [scripts/generate_meta_info.py](scripts/generate_meta_info.py) 生成包含图像路径的 txt 文件。<br>
|
67 |
+
你还可以合并多个文件夹的图像路径到一个元信息(meta_info)txt。这是使用示例:
|
68 |
+
|
69 |
+
```bash
|
70 |
+
python scripts/generate_meta_info.py --input datasets/DF2K/DF2K_HR, datasets/DF2K/DF2K_multiscale --root datasets/DF2K, datasets/DF2K --meta_info datasets/DF2K/meta_info/meta_info_DF2Kmultiscale.txt
|
71 |
+
```
|
72 |
+
|
73 |
+
### 训练 Real-ESRNet 模型
|
74 |
+
|
75 |
+
1. 下载预先训练的模型 [ESRGAN](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/ESRGAN_SRx4_DF2KOST_official-ff704c30.pth),放到 `experiments/pretrained_models`目录下。
|
76 |
+
```bash
|
77 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/ESRGAN_SRx4_DF2KOST_official-ff704c30.pth -P experiments/pretrained_models
|
78 |
+
```
|
79 |
+
2. 相应地修改选项文件 `options/train_realesrnet_x4plus.yml` 中的内容:
|
80 |
+
```yml
|
81 |
+
train:
|
82 |
+
name: DF2K+OST
|
83 |
+
type: RealESRGANDataset
|
84 |
+
dataroot_gt: datasets/DF2K # 修改为你的数据集文件夹根目录
|
85 |
+
meta_info: realesrgan/meta_info/meta_info_DF2Kmultiscale+OST_sub.txt # 修改为你自己生成的元信息txt
|
86 |
+
io_backend:
|
87 |
+
type: disk
|
88 |
+
```
|
89 |
+
3. 如果你想在训练过程中执行验证,就取消注释这些内容并进行相应的修改:
|
90 |
+
```yml
|
91 |
+
# 取消注释这些以进行验证
|
92 |
+
# val:
|
93 |
+
# name: validation
|
94 |
+
# type: PairedImageDataset
|
95 |
+
# dataroot_gt: path_to_gt
|
96 |
+
# dataroot_lq: path_to_lq
|
97 |
+
# io_backend:
|
98 |
+
# type: disk
|
99 |
+
|
100 |
+
...
|
101 |
+
|
102 |
+
# 取消注释这些以进行验证
|
103 |
+
# 验证设置
|
104 |
+
# val:
|
105 |
+
# val_freq: !!float 5e3
|
106 |
+
# save_img: True
|
107 |
+
|
108 |
+
# metrics:
|
109 |
+
# psnr: # 指标名称,可以是任意的
|
110 |
+
# type: calculate_psnr
|
111 |
+
# crop_border: 4
|
112 |
+
# test_y_channel: false
|
113 |
+
```
|
114 |
+
4. 正式训练之前,你可以用 `--debug` 模式检查是否正常运行。我们用了4个GPU进行训练:
|
115 |
+
```bash
|
116 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
117 |
+
python -m torch.distributed.launch --nproc_per_node=4 --master_port=4321 realesrgan/train.py -opt options/train_realesrnet_x4plus.yml --launcher pytorch --debug
|
118 |
+
```
|
119 |
+
|
120 |
+
用 **1个GPU** 训练的 debug 模式示例:
|
121 |
+
```bash
|
122 |
+
python realesrgan/train.py -opt options/train_realesrnet_x4plus.yml --debug
|
123 |
+
```
|
124 |
+
5. 正式训练开始。我们用了4个GPU进行训练。还可以使用参数 `--auto_resume` 在必要时自动恢复训练。
|
125 |
+
```bash
|
126 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
127 |
+
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
|
128 |
+
```
|
129 |
+
|
130 |
+
用 **1个GPU** 训练:
|
131 |
+
```bash
|
132 |
+
python realesrgan/train.py -opt options/train_realesrnet_x4plus.yml --auto_resume
|
133 |
+
```
|
134 |
+
|
135 |
+
### 训练 Real-ESRGAN 模型
|
136 |
+
|
137 |
+
1. 训练 Real-ESRNet 模型后,您得到了这个 `experiments/train_RealESRNetx4plus_1000k_B12G4_fromESRGAN/model/net_g_1000000.pth` 文件。如果需要指定预训练路径到其他文件,请修改选项文件 `train_realesrgan_x4plus.yml` 中 `pretrain_network_g` 的值。
|
138 |
+
1. 修改选项文件 `train_realesrgan_x4plus.yml` 的内容。大多数修改与上节提到的类似。
|
139 |
+
1. 正式训练之前,你可以以 `--debug` 模式检查是否正常运行。我们使用了4个GPU进行训练:
|
140 |
+
```bash
|
141 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
142 |
+
python -m torch.distributed.launch --nproc_per_node=4 --master_port=4321 realesrgan/train.py -opt options/train_realesrgan_x4plus.yml --launcher pytorch --debug
|
143 |
+
```
|
144 |
+
|
145 |
+
用 **1个GPU** 训练的 debug 模式示例:
|
146 |
+
```bash
|
147 |
+
python realesrgan/train.py -opt options/train_realesrgan_x4plus.yml --debug
|
148 |
+
```
|
149 |
+
1. 正式训练开始。我们使用4个GPU进行训练。还可以使用参数 `--auto_resume` 在必要时自动恢复训练。
|
150 |
+
```bash
|
151 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
152 |
+
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
|
153 |
+
```
|
154 |
+
|
155 |
+
用 **1个GPU** 训练:
|
156 |
+
```bash
|
157 |
+
python realesrgan/train.py -opt options/train_realesrgan_x4plus.yml --auto_resume
|
158 |
+
```
|
159 |
+
|
160 |
+
## 用自己的数据集微调 Real-ESRGAN
|
161 |
+
|
162 |
+
你可以用自己的数据集微调 Real-ESRGAN。一般地,微调(Fine-Tune)程序可以分为两种类型:
|
163 |
+
|
164 |
+
1. [动态生成降级图像](#动态生成降级图像)
|
165 |
+
2. [使用**已配对**的数据](#使用已配对的数据)
|
166 |
+
|
167 |
+
### 动态生成降级图像
|
168 |
+
|
169 |
+
只需要高分辨率图像。在训练过程中,使用 Real-ESRGAN 描述的降级模型生成低质量图像。
|
170 |
+
|
171 |
+
**1. 准备数据集**
|
172 |
+
|
173 |
+
完整信息请参见[本节](#准备数据集)。
|
174 |
+
|
175 |
+
**2. 下载预训练模型**
|
176 |
+
|
177 |
+
下载预先训练的模型到 `experiments/pretrained_models` 目录下。
|
178 |
+
|
179 |
+
- *RealESRGAN_x4plus.pth*:
|
180 |
+
```bash
|
181 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P experiments/pretrained_models
|
182 |
+
```
|
183 |
+
|
184 |
+
- *RealESRGAN_x4plus_netD.pth*:
|
185 |
+
```bash
|
186 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x4plus_netD.pth -P experiments/pretrained_models
|
187 |
+
```
|
188 |
+
|
189 |
+
**3. 微调**
|
190 |
+
|
191 |
+
修改选项文件 [options/finetune_realesrgan_x4plus.yml](options/finetune_realesrgan_x4plus.yml) ,特别是 `datasets` 部分:
|
192 |
+
|
193 |
+
```yml
|
194 |
+
train:
|
195 |
+
name: DF2K+OST
|
196 |
+
type: RealESRGANDataset
|
197 |
+
dataroot_gt: datasets/DF2K # 修改为你的数据集文件夹根目录
|
198 |
+
meta_info: realesrgan/meta_info/meta_info_DF2Kmultiscale+OST_sub.txt # 修改为你自己生成的元信息txt
|
199 |
+
io_backend:
|
200 |
+
type: disk
|
201 |
+
```
|
202 |
+
|
203 |
+
我们使用4个GPU进行训练。还可以使用参数 `--auto_resume` 在必要时自动恢复训练。
|
204 |
+
|
205 |
+
```bash
|
206 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
207 |
+
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
|
208 |
+
```
|
209 |
+
|
210 |
+
用 **1个GPU** 训练:
|
211 |
+
```bash
|
212 |
+
python realesrgan/train.py -opt options/finetune_realesrgan_x4plus.yml --auto_resume
|
213 |
+
```
|
214 |
+
|
215 |
+
### 使用已配对的数据
|
216 |
+
|
217 |
+
你还可以用自己已经配对的数据微调 RealESRGAN。这个过程更类似于微调 ESRGAN。
|
218 |
+
|
219 |
+
**1. 准备数据集**
|
220 |
+
|
221 |
+
假设你已经有两个文件夹(folder):
|
222 |
+
|
223 |
+
- **gt folder**(标准参考,高分辨率图像):*datasets/DF2K/DIV2K_train_HR_sub*
|
224 |
+
- **lq folder**(低质量,低分辨率图像):*datasets/DF2K/DIV2K_train_LR_bicubic_X4_sub*
|
225 |
+
|
226 |
+
然后,您可以使用脚本 [scripts/generate_meta_info_pairdata.py](scripts/generate_meta_info_pairdata.py) 生成元信息(meta_info)txt 文件。
|
227 |
+
|
228 |
+
```bash
|
229 |
+
python scripts/generate_meta_info_pairdata.py --input datasets/DF2K/DIV2K_train_HR_sub datasets/DF2K/DIV2K_train_LR_bicubic_X4_sub --meta_info datasets/DF2K/meta_info/meta_info_DIV2K_sub_pair.txt
|
230 |
+
```
|
231 |
+
|
232 |
+
**2. 下载预训练模型**
|
233 |
+
|
234 |
+
下载预先训练的模型到 `experiments/pretrained_models` 目录下。
|
235 |
+
|
236 |
+
- *RealESRGAN_x4plus.pth*:
|
237 |
+
```bash
|
238 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P experiments/pretrained_models
|
239 |
+
```
|
240 |
+
|
241 |
+
- *RealESRGAN_x4plus_netD.pth*:
|
242 |
+
```bash
|
243 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x4plus_netD.pth -P experiments/pretrained_models
|
244 |
+
```
|
245 |
+
|
246 |
+
**3. 微调**
|
247 |
+
|
248 |
+
修改选项文件 [options/finetune_realesrgan_x4plus_pairdata.yml](options/finetune_realesrgan_x4plus_pairdata.yml) ,特别是 `datasets` 部分:
|
249 |
+
|
250 |
+
```yml
|
251 |
+
train:
|
252 |
+
name: DIV2K
|
253 |
+
type: RealESRGANPairedDataset
|
254 |
+
dataroot_gt: datasets/DF2K # 修改为你的 gt folder 文件夹根目录
|
255 |
+
dataroot_lq: datasets/DF2K # 修改为你的 lq folder 文件夹根目录
|
256 |
+
meta_info: datasets/DF2K/meta_info/meta_info_DIV2K_sub_pair.txt # 修改为你自己生成的元信息txt
|
257 |
+
io_backend:
|
258 |
+
type: disk
|
259 |
+
```
|
260 |
+
|
261 |
+
我们使用4个GPU进行训练。还可以使用参数 `--auto_resume` 在必要时自动恢复训练。
|
262 |
+
|
263 |
+
```bash
|
264 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
|
265 |
+
python -m torch.distributed.launch --nproc_per_node=4 --master_port=4321 realesrgan/train.py -opt options/finetune_realesrgan_x4plus_pairdata.yml --launcher pytorch --auto_resume
|
266 |
+
```
|
267 |
+
|
268 |
+
用 **1个GPU** 训练:
|
269 |
+
```bash
|
270 |
+
python realesrgan/train.py -opt options/finetune_realesrgan_x4plus_pairdata.yml --auto_resume
|
271 |
+
```
|
docs/anime_comparisons.md
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Comparisons among different anime models
|
2 |
+
|
3 |
+
[English](anime_comparisons.md) **|** [简体中文](anime_comparisons_CN.md)
|
4 |
+
|
5 |
+
## Update News
|
6 |
+
|
7 |
+
- 2022/04/24: Release **AnimeVideo-v3**. We have made the following improvements:
|
8 |
+
- **better naturalness**
|
9 |
+
- **Fewer artifacts**
|
10 |
+
- **more faithful to the original colors**
|
11 |
+
- **better texture restoration**
|
12 |
+
- **better background restoration**
|
13 |
+
|
14 |
+
## Comparisons
|
15 |
+
|
16 |
+
We have compared our RealESRGAN-AnimeVideo-v3 with the following methods.
|
17 |
+
Our RealESRGAN-AnimeVideo-v3 can achieve better results with faster inference speed.
|
18 |
+
|
19 |
+
- [waifu2x](https://github.com/nihui/waifu2x-ncnn-vulkan) with the hyperparameters: `tile=0`, `noiselevel=2`
|
20 |
+
- [Real-CUGAN](https://github.com/bilibili/ailab/tree/main/Real-CUGAN): we use the [20220227](https://github.com/bilibili/ailab/releases/tag/Real-CUGAN-add-faster-low-memory-mode) version, the hyperparameters are: `cache_mode=0`, `tile=0`, `alpha=1`.
|
21 |
+
- our RealESRGAN-AnimeVideo-v3
|
22 |
+
|
23 |
+
## Results
|
24 |
+
|
25 |
+
You may need to **zoom in** for comparing details, or **click the image** to see in the full size. Please note that the images
|
26 |
+
in the table below are the resized and cropped patches from the original images, you can download the original inputs and outputs from [Google Drive](https://drive.google.com/drive/folders/1bc_Hje1Nqop9NDkUvci2VACSjL7HZMRp?usp=sharing) .
|
27 |
+
|
28 |
+
**More natural results, better background restoration**
|
29 |
+
| Input | waifu2x | Real-CUGAN | RealESRGAN<br>AnimeVideo-v3 |
|
30 |
+
| :---: | :---: | :---: | :---: |
|
31 |
+
|![157083983-bec52c67-9a5e-4eed-afef-01fe6cd2af85_patch](https://user-images.githubusercontent.com/11482921/164452769-5d8cb4f8-1708-42d2-b941-f44a6f136feb.png) | ![](https://user-images.githubusercontent.com/11482921/164452767-c825cdec-f721-4ff1-aef1-fec41f146c4c.png) | ![](https://user-images.githubusercontent.com/11482921/164452755-3be50895-e3d4-432d-a7b9-9085c2a8e771.png) | ![](https://user-images.githubusercontent.com/11482921/164452771-be300656-379a-4323-a755-df8025a8c451.png) |
|
32 |
+
|![a0010_patch](https://user-images.githubusercontent.com/11482921/164454047-22eeb493-3fa9-4142-9fc2-6f2a1c074cd5.png) | ![](https://user-images.githubusercontent.com/11482921/164454046-d5e79f8f-00a0-4b55-bc39-295d0d69747a.png) | ![](https://user-images.githubusercontent.com/11482921/164454040-87886b11-9d08-48bd-862f-0d4aed72eb19.png) | ![](https://user-images.githubusercontent.com/11482921/164454055-73dc9f02-286e-4d5c-8f70-c13742e08f42.png) |
|
33 |
+
|![00000044_patch](https://user-images.githubusercontent.com/11482921/164451232-bacf64fc-e55a-44db-afbb-6b31ab0f8973.png) | ![](https://user-images.githubusercontent.com/11482921/164451318-f309b61a-75b8-4b74-b5f3-595725f1cf0b.png) | ![](https://user-images.githubusercontent.com/11482921/164451348-994f8a35-adbe-4a4b-9c61-feaa294af06a.png) | ![](https://user-images.githubusercontent.com/11482921/164451361-9b7d376e-6f75-4648-b752-542b44845d1c.png) |
|
34 |
+
|
35 |
+
**Fewer artifacts, better detailed textures**
|
36 |
+
| Input | waifu2x | Real-CUGAN | RealESRGAN<br>AnimeVideo-v3 |
|
37 |
+
| :---: | :---: | :---: | :---: |
|
38 |
+
|![00000053_patch](https://user-images.githubusercontent.com/11482921/164448411-148a7e5c-cfcd-4504-8bc7-e318eb883bb6.png) | ![](https://user-images.githubusercontent.com/11482921/164448633-dfc15224-b6d2-4403-a3c9-4bb819979364.png) | ![](https://user-images.githubusercontent.com/11482921/164448771-0d359509-5293-4d4c-8e3c-86a2a314ea88.png) | ![](https://user-images.githubusercontent.com/11482921/164448848-1a4ff99e-075b-4458-9db7-2c89e8160aa0.png) |
|
39 |
+
|![Disney_v4_22_018514_s2_patch](https://user-images.githubusercontent.com/11482921/164451898-83311cdf-bd3e-450f-b9f6-34d7fea3ab79.png) | ![](https://user-images.githubusercontent.com/11482921/164451894-6c56521c-6561-40d6-a3a5-8dde2c167b8a.png) | ![](https://user-images.githubusercontent.com/11482921/164451888-af9b47e3-39dc-4f3e-b0d7-d372d8191e2a.png) | ![](https://user-images.githubusercontent.com/11482921/164451901-31ca4dd4-9847-4baa-8cde-ad50f4053dcf.png) |
|
40 |
+
|![Japan_v2_0_007261_s2_patch](https://user-images.githubusercontent.com/11482921/164454578-73c77392-77de-49c5-b03c-c36631723192.png) | ![](https://user-images.githubusercontent.com/11482921/164454574-b1ede5f0-4520-4eaa-8f59-086751a34e62.png) | ![](https://user-images.githubusercontent.com/11482921/164454567-4cb3fdd8-6a2d-4016-85b2-a305a8ff80e4.png) | ![](https://user-images.githubusercontent.com/11482921/164454583-7f243f20-eca3-4500-ac43-eb058a4a101a.png) |
|
41 |
+
|![huluxiongdi_2_patch](https://user-images.githubusercontent.com/11482921/164453482-0726c842-337e-40ec-bf6c-f902ee956a8b.png) | ![](https://user-images.githubusercontent.com/11482921/164453480-71d5e091-5bfa-4c77-9c57-4e37f66ca0a3.png) | ![](https://user-images.githubusercontent.com/11482921/164453468-c295d3c9-3661-45f0-9ecd-406a1877f76e.png) | ![](https://user-images.githubusercontent.com/11482921/164453486-3091887c-587c-450e-b6fe-905cb518d57e.png) |
|
42 |
+
|
43 |
+
**Other better results**
|
44 |
+
| Input | waifu2x | Real-CUGAN | RealESRGAN<br>AnimeVideo-v3 |
|
45 |
+
| :---: | :---: | :---: | :---: |
|
46 |
+
|![Japan_v2_1_128525_s1_patch](https://user-images.githubusercontent.com/11482921/164454933-67697f7c-b6ef-47dc-bfca-822a78af8acf.png) | ![](https://user-images.githubusercontent.com/11482921/164454931-9450de7c-f0b3-4638-9c1e-0668e0c41ef0.png) | ![](https://user-images.githubusercontent.com/11482921/164454926-ed746976-786d-41c5-8a83-7693cd774c3a.png) | ![](https://user-images.githubusercontent.com/11482921/164454936-8abdf0f0-fb30-40eb-8281-3b46c0bcb9ae.png) |
|
47 |
+
|![tianshuqitan_2_patch](https://user-images.githubusercontent.com/11482921/164456948-807c1476-90b6-4507-81da-cb986d01600c.png) | ![](https://user-images.githubusercontent.com/11482921/164456943-25e89de9-d7e5-4f61-a2e1-96786af6ae9e.png) | ![](https://user-images.githubusercontent.com/11482921/164456954-b468c447-59f5-4594-9693-3683e44ba3e6.png) | ![](https://user-images.githubusercontent.com/11482921/164456957-640f910c-3b04-407c-ac20-044d72e19735.png) |
|
48 |
+
|![00000051_patch](https://user-images.githubusercontent.com/11482921/164456044-e9a6b3fa-b24e-4eb7-acf9-1f7746551b1e.png) ![00000051_patch](https://user-images.githubusercontent.com/11482921/164456421-b67245b0-767d-4250-9105-80bbe507ecfc.png) | ![](https://user-images.githubusercontent.com/11482921/164456040-85763cf2-cb28-4ba3-abb6-1dbb48c55713.png) ![](https://user-images.githubusercontent.com/11482921/164456419-59cf342e-bc1e-4044-868c-e1090abad313.png) | ![](https://user-images.githubusercontent.com/11482921/164456031-4244bb7b-8649-4e01-86f4-40c2099c5afd.png) ![](https://user-images.githubusercontent.com/11482921/164456411-b6afcbe9-c054-448d-a6df-96d3ba3047f8.png) | ![](https://user-images.githubusercontent.com/11482921/164456035-12e270be-fd52-46d4-b18a-3d3b680731fe.png) ![](https://user-images.githubusercontent.com/11482921/164456417-dcaa8b62-f497-427d-b2d2-f390f1200fb9.png) |
|
49 |
+
|![00000099_patch](https://user-images.githubusercontent.com/11482921/164455312-6411b6e1-5823-4131-a4b0-a6be8a9ae89f.png) | ![](https://user-images.githubusercontent.com/11482921/164455310-f2b99646-3a22-47a4-805b-dc451ac86ddb.png) | ![](https://user-images.githubusercontent.com/11482921/164455294-35471b42-2826-4451-b7ec-6de01344954c.png) | ![](https://user-images.githubusercontent.com/11482921/164455305-fa4c9758-564a-4081-8b4e-f11057a0404d.png) |
|
50 |
+
|![00000016_patch](https://user-images.githubusercontent.com/11482921/164455672-447353c9-2da2-4fcb-ba4a-7dd6b94c19c1.png) | ![](https://user-images.githubusercontent.com/11482921/164455669-df384631-baaa-42f8-9150-40f658471558.png) | ![](https://user-images.githubusercontent.com/11482921/164455657-68006bf0-138d-4981-aaca-8aa927d2f78a.png) | ![](https://user-images.githubusercontent.com/11482921/164455664-0342b93e-a62a-4b36-a90e-7118f3f1e45d.png) |
|
51 |
+
|
52 |
+
## Inference Speed
|
53 |
+
|
54 |
+
### PyTorch
|
55 |
+
|
56 |
+
Note that we only report the **model** time, and ignore the IO time.
|
57 |
+
|
58 |
+
| GPU | Input Resolution | waifu2x | Real-CUGAN | RealESRGAN-AnimeVideo-v3
|
59 |
+
| :---: | :---: | :---: | :---: | :---: |
|
60 |
+
| V100 | 1921 x 1080 | - | 3.4 fps | **10.0** fps |
|
61 |
+
| V100 | 1280 x 720 | - | 7.2 fps | **22.6** fps |
|
62 |
+
| V100 | 640 x 480 | - | 24.4 fps | **65.9** fps |
|
63 |
+
|
64 |
+
### ncnn
|
65 |
+
|
66 |
+
- [ ] TODO
|
docs/anime_comparisons_CN.md
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 动漫视频模型比较
|
2 |
+
|
3 |
+
[English](anime_comparisons.md) **|** [简体中文](anime_comparisons_CN.md)
|
4 |
+
|
5 |
+
## 更新
|
6 |
+
|
7 |
+
- 2022/04/24: 发布 **AnimeVideo-v3**. 主要做了以下更新:
|
8 |
+
- **更自然**
|
9 |
+
- **更少瑕疵**
|
10 |
+
- **颜色保持得更好**
|
11 |
+
- **更好的纹理恢复**
|
12 |
+
- **虚化背景处理**
|
13 |
+
|
14 |
+
## 比较
|
15 |
+
|
16 |
+
我们将 RealESRGAN-AnimeVideo-v3 与以下方法进行了比较。我们的 RealESRGAN-AnimeVideo-v3 可以以更快的推理速度获得更好的结果。
|
17 |
+
|
18 |
+
- [waifu2x](https://github.com/nihui/waifu2x-ncnn-vulkan). 超参数: `tile=0`, `noiselevel=2`
|
19 |
+
- [Real-CUGAN](https://github.com/bilibili/ailab/tree/main/Real-CUGAN): 我们使用了[20220227](https://github.com/bilibili/ailab/releases/tag/Real-CUGAN-add-faster-low-memory-mode)版本, 超参: `cache_mode=0`, `tile=0`, `alpha=1`.
|
20 |
+
- 我们的 RealESRGAN-AnimeVideo-v3
|
21 |
+
|
22 |
+
## 结果
|
23 |
+
|
24 |
+
您可能需要**放大**以比较详细信息, 或者**单击图像**以查看完整尺寸。 请注意下面表格的图片是从原图里裁剪patch并且resize后的结果,您可以从
|
25 |
+
[Google Drive](https://drive.google.com/drive/folders/1bc_Hje1Nqop9NDkUvci2VACSjL7HZMRp?usp=sharing) 里下载原始的输入和输出。
|
26 |
+
|
27 |
+
**更自然的结果,更好的虚化背景恢复**
|
28 |
+
|
29 |
+
| 输入 | waifu2x | Real-CUGAN | RealESRGAN<br>AnimeVideo-v3 |
|
30 |
+
| :---: | :---: | :---: | :---: |
|
31 |
+
|![157083983-bec52c67-9a5e-4eed-afef-01fe6cd2af85_patch](https://user-images.githubusercontent.com/11482921/164452769-5d8cb4f8-1708-42d2-b941-f44a6f136feb.png) | ![](https://user-images.githubusercontent.com/11482921/164452767-c825cdec-f721-4ff1-aef1-fec41f146c4c.png) | ![](https://user-images.githubusercontent.com/11482921/164452755-3be50895-e3d4-432d-a7b9-9085c2a8e771.png) | ![](https://user-images.githubusercontent.com/11482921/164452771-be300656-379a-4323-a755-df8025a8c451.png) |
|
32 |
+
|![a0010_patch](https://user-images.githubusercontent.com/11482921/164454047-22eeb493-3fa9-4142-9fc2-6f2a1c074cd5.png) | ![](https://user-images.githubusercontent.com/11482921/164454046-d5e79f8f-00a0-4b55-bc39-295d0d69747a.png) | ![](https://user-images.githubusercontent.com/11482921/164454040-87886b11-9d08-48bd-862f-0d4aed72eb19.png) | ![](https://user-images.githubusercontent.com/11482921/164454055-73dc9f02-286e-4d5c-8f70-c13742e08f42.png) |
|
33 |
+
|![00000044_patch](https://user-images.githubusercontent.com/11482921/164451232-bacf64fc-e55a-44db-afbb-6b31ab0f8973.png) | ![](https://user-images.githubusercontent.com/11482921/164451318-f309b61a-75b8-4b74-b5f3-595725f1cf0b.png) | ![](https://user-images.githubusercontent.com/11482921/164451348-994f8a35-adbe-4a4b-9c61-feaa294af06a.png) | ![](https://user-images.githubusercontent.com/11482921/164451361-9b7d376e-6f75-4648-b752-542b44845d1c.png) |
|
34 |
+
|
35 |
+
**更少瑕疵,更好的细节纹理**
|
36 |
+
|
37 |
+
| 输入 | waifu2x | Real-CUGAN | RealESRGAN<br>AnimeVideo-v3 |
|
38 |
+
| :---: | :---: | :---: | :---: |
|
39 |
+
|![00000053_patch](https://user-images.githubusercontent.com/11482921/164448411-148a7e5c-cfcd-4504-8bc7-e318eb883bb6.png) | ![](https://user-images.githubusercontent.com/11482921/164448633-dfc15224-b6d2-4403-a3c9-4bb819979364.png) | ![](https://user-images.githubusercontent.com/11482921/164448771-0d359509-5293-4d4c-8e3c-86a2a314ea88.png) | ![](https://user-images.githubusercontent.com/11482921/164448848-1a4ff99e-075b-4458-9db7-2c89e8160aa0.png) |
|
40 |
+
|![Disney_v4_22_018514_s2_patch](https://user-images.githubusercontent.com/11482921/164451898-83311cdf-bd3e-450f-b9f6-34d7fea3ab79.png) | ![](https://user-images.githubusercontent.com/11482921/164451894-6c56521c-6561-40d6-a3a5-8dde2c167b8a.png) | ![](https://user-images.githubusercontent.com/11482921/164451888-af9b47e3-39dc-4f3e-b0d7-d372d8191e2a.png) | ![](https://user-images.githubusercontent.com/11482921/164451901-31ca4dd4-9847-4baa-8cde-ad50f4053dcf.png) |
|
41 |
+
|![Japan_v2_0_007261_s2_patch](https://user-images.githubusercontent.com/11482921/164454578-73c77392-77de-49c5-b03c-c36631723192.png) | ![](https://user-images.githubusercontent.com/11482921/164454574-b1ede5f0-4520-4eaa-8f59-086751a34e62.png) | ![](https://user-images.githubusercontent.com/11482921/164454567-4cb3fdd8-6a2d-4016-85b2-a305a8ff80e4.png) | ![](https://user-images.githubusercontent.com/11482921/164454583-7f243f20-eca3-4500-ac43-eb058a4a101a.png) |
|
42 |
+
|![huluxiongdi_2_patch](https://user-images.githubusercontent.com/11482921/164453482-0726c842-337e-40ec-bf6c-f902ee956a8b.png) | ![](https://user-images.githubusercontent.com/11482921/164453480-71d5e091-5bfa-4c77-9c57-4e37f66ca0a3.png) | ![](https://user-images.githubusercontent.com/11482921/164453468-c295d3c9-3661-45f0-9ecd-406a1877f76e.png) | ![](https://user-images.githubusercontent.com/11482921/164453486-3091887c-587c-450e-b6fe-905cb518d57e.png) |
|
43 |
+
|
44 |
+
**其他更好的结果**
|
45 |
+
|
46 |
+
| 输入 | waifu2x | Real-CUGAN | RealESRGAN<br>AnimeVideo-v3 |
|
47 |
+
| :---: | :---: | :---: | :---: |
|
48 |
+
|![Japan_v2_1_128525_s1_patch](https://user-images.githubusercontent.com/11482921/164454933-67697f7c-b6ef-47dc-bfca-822a78af8acf.png) | ![](https://user-images.githubusercontent.com/11482921/164454931-9450de7c-f0b3-4638-9c1e-0668e0c41ef0.png) | ![](https://user-images.githubusercontent.com/11482921/164454926-ed746976-786d-41c5-8a83-7693cd774c3a.png) | ![](https://user-images.githubusercontent.com/11482921/164454936-8abdf0f0-fb30-40eb-8281-3b46c0bcb9ae.png) |
|
49 |
+
|![tianshuqitan_2_patch](https://user-images.githubusercontent.com/11482921/164456948-807c1476-90b6-4507-81da-cb986d01600c.png) | ![](https://user-images.githubusercontent.com/11482921/164456943-25e89de9-d7e5-4f61-a2e1-96786af6ae9e.png) | ![](https://user-images.githubusercontent.com/11482921/164456954-b468c447-59f5-4594-9693-3683e44ba3e6.png) | ![](https://user-images.githubusercontent.com/11482921/164456957-640f910c-3b04-407c-ac20-044d72e19735.png) |
|
50 |
+
|![00000051_patch](https://user-images.githubusercontent.com/11482921/164456044-e9a6b3fa-b24e-4eb7-acf9-1f7746551b1e.png) ![00000051_patch](https://user-images.githubusercontent.com/11482921/164456421-b67245b0-767d-4250-9105-80bbe507ecfc.png) | ![](https://user-images.githubusercontent.com/11482921/164456040-85763cf2-cb28-4ba3-abb6-1dbb48c55713.png) ![](https://user-images.githubusercontent.com/11482921/164456419-59cf342e-bc1e-4044-868c-e1090abad313.png) | ![](https://user-images.githubusercontent.com/11482921/164456031-4244bb7b-8649-4e01-86f4-40c2099c5afd.png) ![](https://user-images.githubusercontent.com/11482921/164456411-b6afcbe9-c054-448d-a6df-96d3ba3047f8.png) | ![](https://user-images.githubusercontent.com/11482921/164456035-12e270be-fd52-46d4-b18a-3d3b680731fe.png) ![](https://user-images.githubusercontent.com/11482921/164456417-dcaa8b62-f497-427d-b2d2-f390f1200fb9.png) |
|
51 |
+
|![00000099_patch](https://user-images.githubusercontent.com/11482921/164455312-6411b6e1-5823-4131-a4b0-a6be8a9ae89f.png) | ![](https://user-images.githubusercontent.com/11482921/164455310-f2b99646-3a22-47a4-805b-dc451ac86ddb.png) | ![](https://user-images.githubusercontent.com/11482921/164455294-35471b42-2826-4451-b7ec-6de01344954c.png) | ![](https://user-images.githubusercontent.com/11482921/164455305-fa4c9758-564a-4081-8b4e-f11057a0404d.png) |
|
52 |
+
|![00000016_patch](https://user-images.githubusercontent.com/11482921/164455672-447353c9-2da2-4fcb-ba4a-7dd6b94c19c1.png) | ![](https://user-images.githubusercontent.com/11482921/164455669-df384631-baaa-42f8-9150-40f658471558.png) | ![](https://user-images.githubusercontent.com/11482921/164455657-68006bf0-138d-4981-aaca-8aa927d2f78a.png) | ![](https://user-images.githubusercontent.com/11482921/164455664-0342b93e-a62a-4b36-a90e-7118f3f1e45d.png) |
|
53 |
+
|
54 |
+
## 推理速度比较
|
55 |
+
|
56 |
+
### PyTorch
|
57 |
+
|
58 |
+
请注意,我们只报告了**模型推理**的时间, 而忽略了读写硬盘的时间.
|
59 |
+
|
60 |
+
| GPU | 输入尺寸 | waifu2x | Real-CUGAN | RealESRGAN-AnimeVideo-v3
|
61 |
+
| :---: | :---: | :---: | :---: | :---: |
|
62 |
+
| V100 | 1921 x 1080 | - | 3.4 fps | **10.0** fps |
|
63 |
+
| V100 | 1280 x 720 | - | 7.2 fps | **22.6** fps |
|
64 |
+
| V100 | 640 x 480 | - | 24.4 fps | **65.9** fps |
|
65 |
+
|
66 |
+
### ncnn
|
67 |
+
|
68 |
+
- [ ] TODO
|
docs/anime_model.md
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Anime Model
|
2 |
+
|
3 |
+
:white_check_mark: We add [*RealESRGAN_x4plus_anime_6B.pth*](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth), which is optimized for **anime** images with much smaller model size.
|
4 |
+
|
5 |
+
- [How to Use](#how-to-use)
|
6 |
+
- [PyTorch Inference](#pytorch-inference)
|
7 |
+
- [ncnn Executable File](#ncnn-executable-file)
|
8 |
+
- [Comparisons with waifu2x](#comparisons-with-waifu2x)
|
9 |
+
- [Comparisons with Sliding Bars](#comparisons-with-sliding-bars)
|
10 |
+
|
11 |
+
<p align="center">
|
12 |
+
<img src="https://raw.githubusercontent.com/xinntao/public-figures/master/Real-ESRGAN/cmp_realesrgan_anime_1.png">
|
13 |
+
</p>
|
14 |
+
|
15 |
+
The following is a video comparison with sliding bar. You may need to use the full-screen mode for better visual quality, as the original image is large; otherwise, you may encounter aliasing issue.
|
16 |
+
|
17 |
+
<https://user-images.githubusercontent.com/17445847/131535127-613250d4-f754-4e20-9720-2f9608ad0675.mp4>
|
18 |
+
|
19 |
+
## How to Use
|
20 |
+
|
21 |
+
### PyTorch Inference
|
22 |
+
|
23 |
+
Pre-trained models: [RealESRGAN_x4plus_anime_6B](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth)
|
24 |
+
|
25 |
+
```bash
|
26 |
+
# download model
|
27 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth -P weights
|
28 |
+
# inference
|
29 |
+
python inference_realesrgan.py -n RealESRGAN_x4plus_anime_6B -i inputs
|
30 |
+
```
|
31 |
+
|
32 |
+
### ncnn Executable File
|
33 |
+
|
34 |
+
Download the latest portable [Windows](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-windows.zip) / [Linux](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-ubuntu.zip) / [MacOS](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-macos.zip) **executable files for Intel/AMD/Nvidia GPU**.
|
35 |
+
|
36 |
+
Taking the Windows as example, run:
|
37 |
+
|
38 |
+
```bash
|
39 |
+
./realesrgan-ncnn-vulkan.exe -i input.jpg -o output.png -n realesrgan-x4plus-anime
|
40 |
+
```
|
41 |
+
|
42 |
+
## Comparisons with waifu2x
|
43 |
+
|
44 |
+
We compare Real-ESRGAN-anime with [waifu2x](https://github.com/nihui/waifu2x-ncnn-vulkan). We use the `-n 2 -s 4` for waifu2x.
|
45 |
+
|
46 |
+
<p align="center">
|
47 |
+
<img src="https://raw.githubusercontent.com/xinntao/public-figures/master/Real-ESRGAN/cmp_realesrgan_anime_1.png">
|
48 |
+
</p>
|
49 |
+
<p align="center">
|
50 |
+
<img src="https://raw.githubusercontent.com/xinntao/public-figures/master/Real-ESRGAN/cmp_realesrgan_anime_2.png">
|
51 |
+
</p>
|
52 |
+
<p align="center">
|
53 |
+
<img src="https://raw.githubusercontent.com/xinntao/public-figures/master/Real-ESRGAN/cmp_realesrgan_anime_3.png">
|
54 |
+
</p>
|
55 |
+
<p align="center">
|
56 |
+
<img src="https://raw.githubusercontent.com/xinntao/public-figures/master/Real-ESRGAN/cmp_realesrgan_anime_4.png">
|
57 |
+
</p>
|
58 |
+
<p align="center">
|
59 |
+
<img src="https://raw.githubusercontent.com/xinntao/public-figures/master/Real-ESRGAN/cmp_realesrgan_anime_5.png">
|
60 |
+
</p>
|
61 |
+
|
62 |
+
## Comparisons with Sliding Bars
|
63 |
+
|
64 |
+
The following are video comparisons with sliding bar. You may need to use the full-screen mode for better visual quality, as the original image is large; otherwise, you may encounter aliasing issue.
|
65 |
+
|
66 |
+
<https://user-images.githubusercontent.com/17445847/131536647-a2fbf896-b495-4a9f-b1dd-ca7bbc90101a.mp4>
|
67 |
+
|
68 |
+
<https://user-images.githubusercontent.com/17445847/131536742-6d9d82b6-9765-4296-a15f-18f9aeaa5465.mp4>
|
docs/anime_video_model.md
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Anime Video Models
|
2 |
+
|
3 |
+
:white_check_mark: We add small models that are optimized for anime videos :-)<br>
|
4 |
+
More comparisons can be found in [anime_comparisons.md](anime_comparisons.md)
|
5 |
+
|
6 |
+
- [How to Use](#how-to-use)
|
7 |
+
- [PyTorch Inference](#pytorch-inference)
|
8 |
+
- [ncnn Executable File](#ncnn-executable-file)
|
9 |
+
- [Step 1: Use ffmpeg to extract frames from video](#step-1-use-ffmpeg-to-extract-frames-from-video)
|
10 |
+
- [Step 2: Inference with Real-ESRGAN executable file](#step-2-inference-with-real-esrgan-executable-file)
|
11 |
+
- [Step 3: Merge the enhanced frames back into a video](#step-3-merge-the-enhanced-frames-back-into-a-video)
|
12 |
+
- [More Demos](#more-demos)
|
13 |
+
|
14 |
+
| Models | Scale | Description |
|
15 |
+
| ---------------------------------------------------------------------------------------------------------------------------------- | :---- | :----------------------------- |
|
16 |
+
| [realesr-animevideov3](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth) | X4 <sup>1</sup> | Anime video model with XS size |
|
17 |
+
|
18 |
+
Note: <br>
|
19 |
+
<sup>1</sup> This model can also be used for X1, X2, X3.
|
20 |
+
|
21 |
+
---
|
22 |
+
|
23 |
+
The following are some demos (best view in the full screen mode).
|
24 |
+
|
25 |
+
<https://user-images.githubusercontent.com/17445847/145706977-98bc64a4-af27-481c-8abe-c475e15db7ff.MP4>
|
26 |
+
|
27 |
+
<https://user-images.githubusercontent.com/17445847/145707055-6a4b79cb-3d9d-477f-8610-c6be43797133.MP4>
|
28 |
+
|
29 |
+
<https://user-images.githubusercontent.com/17445847/145783523-f4553729-9f03-44a8-a7cc-782aadf67b50.MP4>
|
30 |
+
|
31 |
+
## How to Use
|
32 |
+
|
33 |
+
### PyTorch Inference
|
34 |
+
|
35 |
+
```bash
|
36 |
+
# download model
|
37 |
+
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth -P weights
|
38 |
+
# single gpu and single process inference
|
39 |
+
CUDA_VISIBLE_DEVICES=0 python inference_realesrgan_video.py -i inputs/video/onepiece_demo.mp4 -n realesr-animevideov3 -s 2 --suffix outx2
|
40 |
+
# single gpu and multi process inference (you can use multi-processing to improve GPU utilization)
|
41 |
+
CUDA_VISIBLE_DEVICES=0 python inference_realesrgan_video.py -i inputs/video/onepiece_demo.mp4 -n realesr-animevideov3 -s 2 --suffix outx2 --num_process_per_gpu 2
|
42 |
+
# multi gpu and multi process inference
|
43 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 python inference_realesrgan_video.py -i inputs/video/onepiece_demo.mp4 -n realesr-animevideov3 -s 2 --suffix outx2 --num_process_per_gpu 2
|
44 |
+
```
|
45 |
+
|
46 |
+
```console
|
47 |
+
Usage:
|
48 |
+
--num_process_per_gpu The total number of process is num_gpu * num_process_per_gpu. The bottleneck of
|
49 |
+
the program lies on the IO, so the GPUs are usually not fully utilized. To alleviate
|
50 |
+
this issue, you can use multi-processing by setting this parameter. As long as it
|
51 |
+
does not exceed the CUDA memory
|
52 |
+
--extract_frame_first If you encounter ffmpeg error when using multi-processing, you can turn this option on.
|
53 |
+
```
|
54 |
+
|
55 |
+
### NCNN Executable File
|
56 |
+
|
57 |
+
#### Step 1: Use ffmpeg to extract frames from video
|
58 |
+
|
59 |
+
```bash
|
60 |
+
ffmpeg -i onepiece_demo.mp4 -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 tmp_frames/frame%08d.png
|
61 |
+
```
|
62 |
+
|
63 |
+
- Remember to create the folder `tmp_frames` ahead
|
64 |
+
|
65 |
+
#### Step 2: Inference with Real-ESRGAN executable file
|
66 |
+
|
67 |
+
1. Download the latest portable [Windows](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-windows.zip) / [Linux](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-ubuntu.zip) / [MacOS](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-macos.zip) **executable files for Intel/AMD/Nvidia GPU**
|
68 |
+
|
69 |
+
1. Taking the Windows as example, run:
|
70 |
+
|
71 |
+
```bash
|
72 |
+
./realesrgan-ncnn-vulkan.exe -i tmp_frames -o out_frames -n realesr-animevideov3 -s 2 -f jpg
|
73 |
+
```
|
74 |
+
|
75 |
+
- Remember to create the folder `out_frames` ahead
|
76 |
+
|
77 |
+
#### Step 3: Merge the enhanced frames back into a video
|
78 |
+
|
79 |
+
1. First obtain fps from input videos by
|
80 |
+
|
81 |
+
```bash
|
82 |
+
ffmpeg -i onepiece_demo.mp4
|
83 |
+
```
|
84 |
+
|
85 |
+
```console
|
86 |
+
Usage:
|
87 |
+
-i input video path
|
88 |
+
```
|
89 |
+
|
90 |
+
You will get the output similar to the following screenshot.
|
91 |
+
|
92 |
+
<p align="center">
|
93 |
+
<img src="https://user-images.githubusercontent.com/17445847/145710145-c4f3accf-b82f-4307-9f20-3803a2c73f57.png">
|
94 |
+
</p>
|
95 |
+
|
96 |
+
2. Merge frames
|
97 |
+
|
98 |
+
```bash
|
99 |
+
ffmpeg -r 23.98 -i out_frames/frame%08d.jpg -c:v libx264 -r 23.98 -pix_fmt yuv420p output.mp4
|
100 |
+
```
|
101 |
+
|
102 |
+
```console
|
103 |
+
Usage:
|
104 |
+
-i input video path
|
105 |
+
-c:v video encoder (usually we use libx264)
|
106 |
+
-r fps, remember to modify it to meet your needs
|
107 |
+
-pix_fmt pixel format in video
|
108 |
+
```
|
109 |
+
|
110 |
+
If you also want to copy audio from the input videos, run:
|
111 |
+
|
112 |
+
```bash
|
113 |
+
ffmpeg -r 23.98 -i out_frames/frame%08d.jpg -i onepiece_demo.mp4 -map 0:v:0 -map 1:a:0 -c:a copy -c:v libx264 -r 23.98 -pix_fmt yuv420p output_w_audio.mp4
|
114 |
+
```
|
115 |
+
|
116 |
+
```console
|
117 |
+
Usage:
|
118 |
+
-i input video path, here we use two input streams
|
119 |
+
-c:v video encoder (usually we use libx264)
|
120 |
+
-r fps, remember to modify it to meet your needs
|
121 |
+
-pix_fmt pixel format in video
|
122 |
+
```
|
123 |
+
|
124 |
+
## More Demos
|
125 |
+
|
126 |
+
- Input video for One Piece:
|
127 |
+
|
128 |
+
<https://user-images.githubusercontent.com/17445847/145706822-0e83d9c4-78ef-40ee-b2a4-d8b8c3692d17.mp4>
|
129 |
+
|
130 |
+
- Out video for One Piece
|
131 |
+
|
132 |
+
<https://user-images.githubusercontent.com/17445847/164960481-759658cf-fcb8-480c-b888-cecb606e8744.mp4>
|
133 |
+
|
134 |
+
**More comparisons**
|
135 |
+
|
136 |
+
<https://user-images.githubusercontent.com/17445847/145707458-04a5e9b9-2edd-4d1f-b400-380a72e5f5e6.MP4>
|
docs/feedback.md
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Feedback 反馈
|
2 |
+
|
3 |
+
## 动漫插画模型
|
4 |
+
|
5 |
+
1. 视频处理不了: 目前的模型,不是针对视频的,所以视频效果很很不好。我们在探究针对视频的模型了
|
6 |
+
1. 景深虚化有问题: 现在的模型把一些景深 和 特意的虚化 都复原了,感觉不好。这个后面我们会考虑把这个信息结合进入。一个简单的做法是识别景深和虚化,然后作为条件告诉神经网络,哪些地方复原强一些,哪些地方复原要弱一些
|
7 |
+
1. 不可以调节: 像 Waifu2X 可以调节。可以根据自己的喜好,做调整,但是 Real-ESRGAN-anime 并不可以。导致有些恢复效果过了
|
8 |
+
1. 把原来的风格改变了: 不同的动漫插画都有自己的风格,现在的 Real-ESRGAN-anime 倾向于恢复成一种风格(这是受到训练数据集影响的)。风格是动漫很重要的一个要素,所以要尽可能保持
|
9 |
+
1. 模型太大: 目前的模型处理太慢,能够更快。这个我们有相关的工作在探究,希望能够尽快有结果,并应用到 Real-ESRGAN 这一系列的模型上
|
10 |
+
|
11 |
+
Thanks for the [detailed and valuable feedbacks/suggestions](https://github.com/xinntao/Real-ESRGAN/issues/131) by [2ji3150](https://github.com/2ji3150).
|
docs/model_zoo.md
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# :european_castle: Model Zoo
|
2 |
+
|
3 |
+
- [For General Images](#for-general-images)
|
4 |
+
- [For Anime Images](#for-anime-images)
|
5 |
+
- [For Anime Videos](#for-anime-videos)
|
6 |
+
|
7 |
+
---
|
8 |
+
|
9 |
+
## For General Images
|
10 |
+
|
11 |
+
| Models | Scale | Description |
|
12 |
+
| ------------------------------------------------------------------------------------------------------------------------------- | :---- | :------------------------------------------- |
|
13 |
+
| [RealESRGAN_x4plus](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth) | X4 | X4 model for general images |
|
14 |
+
| [RealESRGAN_x2plus](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth) | X2 | X2 model for general images |
|
15 |
+
| [RealESRNet_x4plus](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/RealESRNet_x4plus.pth) | X4 | X4 model with MSE loss (over-smooth effects) |
|
16 |
+
| [official ESRGAN_x4](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/ESRGAN_SRx4_DF2KOST_official-ff704c30.pth) | X4 | official ESRGAN model |
|
17 |
+
| [realesr-general-x4v3](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth) | X4 (can also be used for X1, X2, X3) | A tiny small model (consume much fewer GPU memory and time); not too strong deblur and denoise capacity |
|
18 |
+
|
19 |
+
The following models are **discriminators**, which are usually used for fine-tuning.
|
20 |
+
|
21 |
+
| Models | Corresponding model |
|
22 |
+
| ---------------------------------------------------------------------------------------------------------------------- | :------------------ |
|
23 |
+
| [RealESRGAN_x4plus_netD](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x4plus_netD.pth) | RealESRGAN_x4plus |
|
24 |
+
| [RealESRGAN_x2plus_netD](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x2plus_netD.pth) | RealESRGAN_x2plus |
|
25 |
+
|
26 |
+
## For Anime Images / Illustrations
|
27 |
+
|
28 |
+
| Models | Scale | Description |
|
29 |
+
| ------------------------------------------------------------------------------------------------------------------------------ | :---- | :---------------------------------------------------------- |
|
30 |
+
| [RealESRGAN_x4plus_anime_6B](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth) | X4 | Optimized for anime images; 6 RRDB blocks (smaller network) |
|
31 |
+
|
32 |
+
The following models are **discriminators**, which are usually used for fine-tuning.
|
33 |
+
|
34 |
+
| Models | Corresponding model |
|
35 |
+
| ---------------------------------------------------------------------------------------------------------------------------------------- | :------------------------- |
|
36 |
+
| [RealESRGAN_x4plus_anime_6B_netD](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B_netD.pth) | RealESRGAN_x4plus_anime_6B |
|
37 |
+
|
38 |
+
## For Animation Videos
|
39 |
+
|
40 |
+
| Models | Scale | Description |
|
41 |
+
| ---------------------------------------------------------------------------------------------------------------------------------- | :---- | :----------------------------- |
|
42 |
+
| [realesr-animevideov3](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth) | X4<sup>1</sup> | Anime video model with XS size |
|
43 |
+
|
44 |
+
Note: <br>
|
45 |
+
<sup>1</sup> This model can also be used for X1, X2, X3.
|
46 |
+
|
47 |
+
The following models are **discriminators**, which are usually used for fine-tuning.
|
48 |
+
|
49 |
+
TODO
|
docs/ncnn_conversion.md
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Instructions on converting to NCNN models
|
2 |
+
|
3 |
+
1. Convert to onnx model with `scripts/pytorch2onnx.py`. Remember to modify codes accordingly
|
4 |
+
1. Convert onnx model to ncnn model
|
5 |
+
1. `cd ncnn-master\ncnn\build\tools\onnx`
|
6 |
+
1. `onnx2ncnn.exe realesrgan-x4.onnx realesrgan-x4-raw.param realesrgan-x4-raw.bin`
|
7 |
+
1. Optimize ncnn model
|
8 |
+
1. fp16 mode
|
9 |
+
1. `cd ncnn-master\ncnn\build\tools`
|
10 |
+
1. `ncnnoptimize.exe realesrgan-x4-raw.param realesrgan-x4-raw.bin realesrgan-x4.param realesrgan-x4.bin 1`
|
11 |
+
1. Modify the blob name in `realesrgan-x4.param`: `data` and `output`
|