Spaces:
Runtime error
Runtime error
Commit
•
b0ffb5f
1
Parent(s):
1fef300
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from PIL import Image
|
3 |
+
import numpy as np
|
4 |
+
from RealESRGAN import RealESRGAN
|
5 |
+
|
6 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
7 |
+
|
8 |
+
model = RealESRGAN(device, scale=4)
|
9 |
+
model.load_weights('weights/RealESRGAN_x4.pth', download=True)
|
10 |
+
|
11 |
+
path_to_image = 'inputs/lr_image.png'
|
12 |
+
image = Image.open(path_to_image).convert('RGB')
|
13 |
+
|
14 |
+
sr_image = model.predict(image)
|
15 |
+
|
16 |
+
sr_image.save('results/sr_image.png')
|