Spaces:
Runtime error
Runtime error
Upload 4 files
Browse files- README.md +8 -7
- app.py +46 -1
- groot.jpeg +0 -0
- requirements.txt +1 -0
README.md
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 3.
|
|
|
8 |
app_file: app.py
|
9 |
-
pinned:
|
10 |
license: apache-2.0
|
11 |
---
|
12 |
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces
|
|
|
1 |
---
|
2 |
+
title: Face Real ESRGAN 2x 4x 8x
|
3 |
+
emoji: 😻
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: gray
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.44.3
|
8 |
+
python_version: 3.11.5
|
9 |
app_file: app.py
|
10 |
+
pinned: true
|
11 |
license: apache-2.0
|
12 |
---
|
13 |
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
app.py
CHANGED
@@ -1 +1,46 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from PIL import Image
|
3 |
+
from RealESRGAN import RealESRGAN
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
7 |
+
model2 = RealESRGAN(device, scale=2)
|
8 |
+
model2.load_weights('weights/RealESRGAN_x2.pth', download=True)
|
9 |
+
model4 = RealESRGAN(device, scale=4)
|
10 |
+
model4.load_weights('weights/RealESRGAN_x4.pth', download=True)
|
11 |
+
model8 = RealESRGAN(device, scale=8)
|
12 |
+
model8.load_weights('weights/RealESRGAN_x8.pth', download=True)
|
13 |
+
|
14 |
+
|
15 |
+
def inference(image, size):
|
16 |
+
if size == '2x':
|
17 |
+
result = model2.predict(image.convert('RGB'))
|
18 |
+
elif size == '4x':
|
19 |
+
result = model4.predict(image.convert('RGB'))
|
20 |
+
else:
|
21 |
+
result = model8.predict(image.convert('RGB'))
|
22 |
+
if torch.cuda.is_available():
|
23 |
+
torch.cuda.empty_cache()
|
24 |
+
return result
|
25 |
+
|
26 |
+
|
27 |
+
title = "Face Real ESRGAN UpScale: 2x 4x 8x"
|
28 |
+
description = "This is an unofficial demo for Real-ESRGAN. Scales the resolution of a photo. This model shows better results on faces compared to the original version.<br>Telegram BOT: https://t.me/restoration_photo_bot"
|
29 |
+
article = "<div style='text-align: center;'>Twitter <a href='https://twitter.com/DoEvent' target='_blank'>Max Skobeev</a> | <a href='https://huggingface.co/sberbank-ai/Real-ESRGAN' target='_blank'>Model card</a>/<div>"
|
30 |
+
|
31 |
+
|
32 |
+
gr.Interface(inference,
|
33 |
+
[gr.Image(type="pil"),
|
34 |
+
gr.Radio(['2x', '4x', '8x'],
|
35 |
+
type="value",
|
36 |
+
value='2x',
|
37 |
+
label='Resolution model')],
|
38 |
+
gr.Image(type="pil", label="Output"),
|
39 |
+
title=title,
|
40 |
+
description=description,
|
41 |
+
article=article,
|
42 |
+
examples=[['groot.jpeg', "2x"]],
|
43 |
+
allow_flagging='never',
|
44 |
+
cache_examples=False,
|
45 |
+
).queue(concurrency_count=1).launch(show_error=True)
|
46 |
+
|
groot.jpeg
ADDED
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
git+https://github.com/sberbank-ai/Real-ESRGAN.git
|