Ahsen Khaliq
commited on
Commit
·
673ee78
1
Parent(s):
f7cbd98
Update app.py
Browse files
app.py
CHANGED
@@ -12,8 +12,6 @@ torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/5
|
|
12 |
import cv2
|
13 |
import glob
|
14 |
import numpy as np
|
15 |
-
import os
|
16 |
-
import torch
|
17 |
from basicsr.utils import imwrite
|
18 |
from gfpgan import GFPGANer
|
19 |
|
@@ -51,16 +49,10 @@ restorer = GFPGANer(
|
|
51 |
|
52 |
def inference(img):
|
53 |
input_img = cv2.imread(img, cv2.IMREAD_COLOR)
|
54 |
-
# restore faces and background if necessary
|
55 |
cropped_faces, restored_faces, restored_img = restorer.enhance(
|
56 |
input_img, has_aligned=False, only_center_face=False, paste_back=True)
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
# save comparison image
|
61 |
-
cmp_img = np.concatenate((cropped_faces[0], restored_faces[0]), axis=1)
|
62 |
-
|
63 |
-
return Image.fromarray(cmp_img)
|
64 |
|
65 |
title = "GFP-GAN"
|
66 |
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"
|
|
|
12 |
import cv2
|
13 |
import glob
|
14 |
import numpy as np
|
|
|
|
|
15 |
from basicsr.utils import imwrite
|
16 |
from gfpgan import GFPGANer
|
17 |
|
|
|
49 |
|
50 |
def inference(img):
|
51 |
input_img = cv2.imread(img, cv2.IMREAD_COLOR)
|
|
|
52 |
cropped_faces, restored_faces, restored_img = restorer.enhance(
|
53 |
input_img, has_aligned=False, only_center_face=False, paste_back=True)
|
54 |
+
|
55 |
+
return Image.fromarray(restored_faces[0])
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
title = "GFP-GAN"
|
58 |
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"
|