ohayonguy
commited on
Commit
•
beeddbb
1
Parent(s):
9a7cbfe
trying to fix run
Browse files
app.py
CHANGED
@@ -115,24 +115,22 @@ def inference(img, aligned, scale, num_steps):
|
|
115 |
device=device,
|
116 |
model_rootpath=None)
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
output = restored_img
|
126 |
-
except RuntimeError as error:
|
127 |
-
print('Error', error)
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
136 |
if img_mode == 'RGBA': # RGBA images should be saved in png format
|
137 |
extension = 'png'
|
138 |
else:
|
@@ -154,7 +152,7 @@ demo = gr.Interface(
|
|
154 |
inference, [
|
155 |
gr.Image(type="filepath", label="Input"),
|
156 |
gr.Radio(['aligned', 'unaligned'], type="value", value='unaligned', label='Image Alignment'),
|
157 |
-
gr.Number(label="Rescaling factor", value=2),
|
158 |
gr.Number(label="Number of flow steps (a higher value leads to better image quality at the expense of runtime)", value=25),
|
159 |
], [
|
160 |
gr.Image(type="numpy", label="Output (The whole image)"),
|
|
|
115 |
device=device,
|
116 |
model_rootpath=None)
|
117 |
|
118 |
+
has_aligned = True if aligned == 'aligned' else False
|
119 |
+
_, restored_aligned, restored_img = enhance_face(img, face_helper, has_aligned, only_center_face=False,
|
120 |
+
paste_back=True)
|
121 |
+
if has_aligned:
|
122 |
+
output = restored_aligned[0]
|
123 |
+
else:
|
124 |
+
output = restored_img
|
|
|
|
|
|
|
125 |
|
126 |
+
|
127 |
+
# try:
|
128 |
+
# if scale != 2:
|
129 |
+
# interpolation = cv2.INTER_AREA if scale < 2 else cv2.INTER_LANCZOS4
|
130 |
+
# h, w = img.shape[0:2]
|
131 |
+
# output = cv2.resize(output, (int(w * scale / 2), int(h * scale / 2)), interpolation=interpolation)
|
132 |
+
# except Exception as error:
|
133 |
+
# print('Wrong scale input.', error)
|
134 |
if img_mode == 'RGBA': # RGBA images should be saved in png format
|
135 |
extension = 'png'
|
136 |
else:
|
|
|
152 |
inference, [
|
153 |
gr.Image(type="filepath", label="Input"),
|
154 |
gr.Radio(['aligned', 'unaligned'], type="value", value='unaligned', label='Image Alignment'),
|
155 |
+
gr.Number(label="Rescaling factor (the rescaling factor of the final image)", value=2),
|
156 |
gr.Number(label="Number of flow steps (a higher value leads to better image quality at the expense of runtime)", value=25),
|
157 |
], [
|
158 |
gr.Image(type="numpy", label="Output (The whole image)"),
|