README.md 1.93 KB
Newer Older
boomb0om's avatar
boomb0om committed
1
2
3
# Real-ESRGAN
PyTorch implementation of a Real-ESRGAN model trained on custom dataset. This model shows better results on faces compared to the original version. It is also easier to integrate this model into your projects.

boomb0om's avatar
boomb0om committed
4
5
> This is not an official implementation. We partially use code from the [original repository](https://github.com/xinntao/Real-ESRGAN)

boomb0om's avatar
boomb0om committed
6
7
Real-ESRGAN is an upgraded [ESRGAN](https://arxiv.org/abs/1809.00219) trained with pure synthetic data is capable of enhancing details while removing annoying artifacts for common real-world images. 

Igor Pavlov's avatar
Igor Pavlov committed
8
You can try it in [google colab](https://colab.research.google.com/drive/1YlWt--P9w25JUs8bHBOuf8GcMkx-hocP?usp=sharing) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1YlWt--P9w25JUs8bHBOuf8GcMkx-hocP?usp=sharing)
boomb0om's avatar
boomb0om committed
9

Igor Pavlov's avatar
Igor Pavlov committed
10
11
12
- [Paper (Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data)](https://arxiv.org/abs/2107.10833)
- [Original implementation](https://github.com/xinntao/Real-ESRGAN)
- [Huggingface 🤗](https://huggingface.co/sberbank-ai/Real-ESRGAN)
boomb0om's avatar
boomb0om committed
13
14
15

### Installation

Igor Pavlov's avatar
Igor Pavlov committed
16
17
18
```bash
pip install git+https://github.com/sberbank-ai/Real-ESRGAN.git
```
boomb0om's avatar
boomb0om committed
19
20
21
22
23

### Usage

---

boomb0om's avatar
boomb0om committed
24
Basic usage:
boomb0om's avatar
boomb0om committed
25
26
27
28
29

```python
import torch
from PIL import Image
import numpy as np
Igor Pavlov's avatar
Igor Pavlov committed
30
from RealESRGAN import RealESRGAN
boomb0om's avatar
boomb0om committed
31
32
33
34

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

model = RealESRGAN(device, scale=4)
Igor Pavlov's avatar
Igor Pavlov committed
35
model.load_weights('weights/RealESRGAN_x4.pth', download=True)
boomb0om's avatar
boomb0om committed
36

boomb0om's avatar
boomb0om committed
37
path_to_image = 'inputs/lr_image.png'
boomb0om's avatar
boomb0om committed
38
39
40
41
42
43
44
image = Image.open(path_to_image).convert('RGB')

sr_image = model.predict(image)

sr_image.save('results/sr_image.png')
```

boomb0om's avatar
boomb0om committed
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
### Examples

---

Low quality image:

![](inputs/lr_image.png)

Real-ESRGAN result:

![](results/sr_image.png)

---

Low quality image:

![](inputs/lr_face.png)

Real-ESRGAN result:

![](results/sr_face.png)

---

Low quality image:

![](inputs/lr_lion.png)

Real-ESRGAN result:

![](results/sr_lion.png)