Spaces:
Running
on
A10G
Running
on
A10G
Xintao
commited on
Commit
•
e03007b
1
Parent(s):
082c35d
add scale
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ face_enhancer = GFPGANer(
|
|
45 |
os.makedirs('output', exist_ok=True)
|
46 |
|
47 |
|
48 |
-
def inference(img):
|
49 |
img = cv2.imread(img, cv2.IMREAD_UNCHANGED)
|
50 |
|
51 |
h, w = img.shape[0:2]
|
@@ -59,15 +59,18 @@ def inference(img):
|
|
59 |
print('If you encounter CUDA out of memory, try to set --tile with a smaller number.')
|
60 |
else:
|
61 |
extension = 'png'
|
62 |
-
|
|
|
|
|
|
|
63 |
return output
|
64 |
|
65 |
|
66 |
-
title = "
|
67 |
description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
|
68 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
|
69 |
gr.Interface(
|
70 |
-
inference, [gr.inputs.Image(type="filepath", label="Input")],
|
71 |
gr.outputs.Image(type="numpy", label="Output (The whole image)"),
|
72 |
title=title,
|
73 |
description=description,
|
|
|
45 |
os.makedirs('output', exist_ok=True)
|
46 |
|
47 |
|
48 |
+
def inference(img, scale):
|
49 |
img = cv2.imread(img, cv2.IMREAD_UNCHANGED)
|
50 |
|
51 |
h, w = img.shape[0:2]
|
|
|
59 |
print('If you encounter CUDA out of memory, try to set --tile with a smaller number.')
|
60 |
else:
|
61 |
extension = 'png'
|
62 |
+
if scale != 2:
|
63 |
+
h, w = img.shape[0:2]
|
64 |
+
output = cv2.resize((int(w * scale /2), int(h * scale/2)), interpolation=cv2.INTER_LINEAR)
|
65 |
+
output = cv2.cvtColor(output, cv2.COLOR_BGR2RGB)
|
66 |
return output
|
67 |
|
68 |
|
69 |
+
title = "GFPGAN: Practical Face Restoration Algorithm"
|
70 |
description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
|
71 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
|
72 |
gr.Interface(
|
73 |
+
inference, [gr.inputs.Image(type="filepath", label="Input"), gr.inputs.Number(value=2, lable="Rescaling factor")],
|
74 |
gr.outputs.Image(type="numpy", label="Output (The whole image)"),
|
75 |
title=title,
|
76 |
description=description,
|