Spaces:
Running
Running
Xintao
commited on
Commit
·
dc21641
1
Parent(s):
95c11a1
update
Browse files
app.py
CHANGED
|
@@ -41,7 +41,7 @@ face_enhancer_v2 = GFPGANer(
|
|
| 41 |
os.makedirs('output', exist_ok=True)
|
| 42 |
|
| 43 |
def inference(img, version, scale):
|
| 44 |
-
print(
|
| 45 |
img = cv2.imread(img, cv2.IMREAD_UNCHANGED)
|
| 46 |
if len(img.shape) == 3 and img.shape[2] == 4:
|
| 47 |
img_mode = 'RGBA'
|
|
@@ -69,8 +69,8 @@ def inference(img, version, scale):
|
|
| 69 |
interpolation = cv2.INTER_AREA if scale < 2 else cv2.INTER_LANCZOS4
|
| 70 |
h, w = img.shape[0:2]
|
| 71 |
output = cv2.resize(output, (int(w * scale /2), int(h * scale/2)), interpolation=interpolation)
|
| 72 |
-
except:
|
| 73 |
-
print('wrong scale input')
|
| 74 |
if img_mode == 'RGBA': # RGBA images should be saved in png format
|
| 75 |
extension = 'png'
|
| 76 |
else:
|
|
@@ -83,13 +83,8 @@ def inference(img, version, scale):
|
|
| 83 |
|
| 84 |
|
| 85 |
title = "GFPGAN: Practical Face Restoration Algorithm"
|
| 86 |
-
description = r"""
|
| 87 |
-
|
| 88 |
-
<a href="https://github.com/TencentARC/GFPGAN" target='_blank'>
|
| 89 |
-
<img src="https://img.shields.io/github/stars/TencentARC/GFPGAN?style=social" alt="GFPGAN stars" />
|
| 90 |
-
</a>
|
| 91 |
-
|
| 92 |
-
Gradio demo for <a href='https://github.com/TencentARC/GFPGAN' target='_blank'><b>GFPGAN: Towards Real-World Blind Face Restoration with Generative Facial Prior</b></a>.<br>
|
| 93 |
It can be used to restore your **old photos** or improve **AI-generated faces**.<br>
|
| 94 |
To use it, simply upload your image.
|
| 95 |
"""
|
|
|
|
| 41 |
os.makedirs('output', exist_ok=True)
|
| 42 |
|
| 43 |
def inference(img, version, scale):
|
| 44 |
+
print(img, version, scale)
|
| 45 |
img = cv2.imread(img, cv2.IMREAD_UNCHANGED)
|
| 46 |
if len(img.shape) == 3 and img.shape[2] == 4:
|
| 47 |
img_mode = 'RGBA'
|
|
|
|
| 69 |
interpolation = cv2.INTER_AREA if scale < 2 else cv2.INTER_LANCZOS4
|
| 70 |
h, w = img.shape[0:2]
|
| 71 |
output = cv2.resize(output, (int(w * scale /2), int(h * scale/2)), interpolation=interpolation)
|
| 72 |
+
except Exception as error:
|
| 73 |
+
print('wrong scale input.', error)
|
| 74 |
if img_mode == 'RGBA': # RGBA images should be saved in png format
|
| 75 |
extension = 'png'
|
| 76 |
else:
|
|
|
|
| 83 |
|
| 84 |
|
| 85 |
title = "GFPGAN: Practical Face Restoration Algorithm"
|
| 86 |
+
description = r"""
|
| 87 |
+
<a href="https://github.com/TencentARC/GFPGAN" target='_blank'> <img src="https://img.shields.io/github/stars/TencentARC/GFPGAN?style=social" alt="GFPGAN stars" /></a> Gradio demo for <a href='https://github.com/TencentARC/GFPGAN' target='_blank'><b>GFPGAN: Towards Real-World Blind Face Restoration with Generative Facial Prior</b></a>.<br>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
It can be used to restore your **old photos** or improve **AI-generated faces**.<br>
|
| 89 |
To use it, simply upload your image.
|
| 90 |
"""
|