Spaces:
Runtime error
Runtime error
jjourney1125
commited on
Commit
•
0c4e407
1
Parent(s):
f072e72
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import requests
|
|
4 |
import gradio as gr
|
5 |
from PIL import Image
|
6 |
import torch
|
|
|
7 |
|
8 |
model_path = 'experiments/pretrained_models/Swin2SR_RealworldSR_X4_64_BSRGAN_PSNR.pth'
|
9 |
|
@@ -16,16 +17,15 @@ else:
|
|
16 |
print(f'downloading model {model_path}')
|
17 |
open(model_path, 'wb').write(r.content)
|
18 |
|
19 |
-
|
20 |
-
|
|
|
21 |
def inference(img):
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
# img = img.resize((basewidth,hsize), Image.ANTIALIAS)
|
28 |
-
#img.save("test/1.jpg", "JPEG")
|
29 |
os.system('python main_test_swin2sr.py --task real_sr --model_path experiments/pretrained_models/Swin2SR_RealworldSR_X4_64_BSRGAN_PSNR.pth --folder_lq test --scale 4')
|
30 |
return 'results/swin2sr_real_sr_x4/1_Swin2SR.png'
|
31 |
|
@@ -36,7 +36,7 @@ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2209.113
|
|
36 |
examples=[['butterflyx4.png']]
|
37 |
gr.Interface(
|
38 |
inference,
|
39 |
-
"
|
40 |
"image",
|
41 |
title=title,
|
42 |
description=description,
|
|
|
4 |
import gradio as gr
|
5 |
from PIL import Image
|
6 |
import torch
|
7 |
+
import shutil
|
8 |
|
9 |
model_path = 'experiments/pretrained_models/Swin2SR_RealworldSR_X4_64_BSRGAN_PSNR.pth'
|
10 |
|
|
|
17 |
print(f'downloading model {model_path}')
|
18 |
open(model_path, 'wb').write(r.content)
|
19 |
|
20 |
+
|
21 |
+
os.makedirs("test", exist_ok=True)
|
22 |
+
|
23 |
def inference(img):
|
24 |
+
basewidth = 256
|
25 |
+
wpercent = (basewidth/float(img.size[0]))
|
26 |
+
hsize = int((float(img.size[1])*float(wpercent)))
|
27 |
+
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
|
28 |
+
img.save("test/1.png", "PNG")
|
|
|
|
|
29 |
os.system('python main_test_swin2sr.py --task real_sr --model_path experiments/pretrained_models/Swin2SR_RealworldSR_X4_64_BSRGAN_PSNR.pth --folder_lq test --scale 4')
|
30 |
return 'results/swin2sr_real_sr_x4/1_Swin2SR.png'
|
31 |
|
|
|
36 |
examples=[['butterflyx4.png']]
|
37 |
gr.Interface(
|
38 |
inference,
|
39 |
+
gr.inputs.Image(type="pil", label="Input"),
|
40 |
"image",
|
41 |
title=title,
|
42 |
description=description,
|