ohayonguy
commited on
Commit
·
797cd30
1
Parent(s):
10d8fa9
trying to fix daemonic processes error
Browse files
app.py
CHANGED
|
@@ -56,7 +56,7 @@ def enhance_face(img, face_helper, has_aligned, only_center_face=False, paste_ba
|
|
| 56 |
# TODO: even with eye_dist_threshold, it will still introduce wrong detections and restorations.
|
| 57 |
# align and warp each face
|
| 58 |
face_helper.align_warp_face()
|
| 59 |
-
|
| 60 |
# face restoration
|
| 61 |
for cropped_face in face_helper.cropped_faces:
|
| 62 |
# prepare data
|
|
@@ -68,7 +68,7 @@ def enhance_face(img, face_helper, has_aligned, only_center_face=False, paste_ba
|
|
| 68 |
output = pmrf.generate_reconstructions(dummy_x, cropped_face_t, None, 25, device)
|
| 69 |
restored_face = tensor2img(output.squeeze(0), rgb2bgr=True, min_max=(0, 1))
|
| 70 |
except RuntimeError as error:
|
| 71 |
-
print(f'\tFailed inference for
|
| 72 |
restored_face = cropped_face
|
| 73 |
|
| 74 |
restored_face = restored_face.astype('uint8')
|
|
@@ -122,13 +122,12 @@ def inference(img, aligned, scale, num_steps):
|
|
| 122 |
model_rootpath=None)
|
| 123 |
|
| 124 |
has_aligned = True if aligned == 'Yes' else False
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
# output = restored_img
|
| 132 |
|
| 133 |
|
| 134 |
# try:
|
|
|
|
| 56 |
# TODO: even with eye_dist_threshold, it will still introduce wrong detections and restorations.
|
| 57 |
# align and warp each face
|
| 58 |
face_helper.align_warp_face()
|
| 59 |
+
return img, img, img
|
| 60 |
# face restoration
|
| 61 |
for cropped_face in face_helper.cropped_faces:
|
| 62 |
# prepare data
|
|
|
|
| 68 |
output = pmrf.generate_reconstructions(dummy_x, cropped_face_t, None, 25, device)
|
| 69 |
restored_face = tensor2img(output.squeeze(0), rgb2bgr=True, min_max=(0, 1))
|
| 70 |
except RuntimeError as error:
|
| 71 |
+
print(f'\tFailed inference for PMRF: {error}.')
|
| 72 |
restored_face = cropped_face
|
| 73 |
|
| 74 |
restored_face = restored_face.astype('uint8')
|
|
|
|
| 122 |
model_rootpath=None)
|
| 123 |
|
| 124 |
has_aligned = True if aligned == 'Yes' else False
|
| 125 |
+
_, restored_aligned, restored_img = enhance_face(img, face_helper, has_aligned, only_center_face=False,
|
| 126 |
+
paste_back=True)
|
| 127 |
+
if has_aligned:
|
| 128 |
+
output = restored_aligned[0]
|
| 129 |
+
else:
|
| 130 |
+
output = restored_img
|
|
|
|
| 131 |
|
| 132 |
|
| 133 |
# try:
|