ohayonguy
commited on
Commit
·
c19a747
1
Parent(s):
15563ba
fixed drawbox
Browse files
app.py
CHANGED
|
@@ -61,20 +61,16 @@ def generate_reconstructions(pmrf_model, x, y, non_noisy_z0, num_flow_steps, dev
|
|
| 61 |
def enhance_face(img, face_helper, has_aligned, num_flow_steps, only_center_face=False, paste_back=True, scale=2):
|
| 62 |
face_helper.clean_all()
|
| 63 |
|
| 64 |
-
if has_aligned:
|
| 65 |
-
# the input faces are already cropped and aligned
|
| 66 |
img = cv2.resize(img, (512, 512), interpolation=cv2.INTER_LINEAR)
|
| 67 |
face_helper.cropped_faces = [img]
|
| 68 |
else:
|
| 69 |
face_helper.read_image(img)
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
)
|
| 74 |
-
print(f'\tdetect {num_det_faces} faces')
|
| 75 |
# align and warp each face
|
| 76 |
face_helper.align_warp_face()
|
| 77 |
-
|
| 78 |
# face restoration
|
| 79 |
for cropped_face in face_helper.cropped_faces:
|
| 80 |
# prepare data
|
|
|
|
| 61 |
def enhance_face(img, face_helper, has_aligned, num_flow_steps, only_center_face=False, paste_back=True, scale=2):
|
| 62 |
face_helper.clean_all()
|
| 63 |
|
| 64 |
+
if has_aligned: # the inputs are already aligned
|
|
|
|
| 65 |
img = cv2.resize(img, (512, 512), interpolation=cv2.INTER_LINEAR)
|
| 66 |
face_helper.cropped_faces = [img]
|
| 67 |
else:
|
| 68 |
face_helper.read_image(img)
|
| 69 |
+
face_helper.get_face_landmarks_5(only_center_face=only_center_face, resize=640, eye_dist_threshold=5)
|
| 70 |
+
# eye_dist_threshold=5: skip faces whose eye distance is smaller than 5 pixels
|
| 71 |
+
# TODO: even with eye_dist_threshold, it will still introduce wrong detections and restorations.
|
|
|
|
|
|
|
| 72 |
# align and warp each face
|
| 73 |
face_helper.align_warp_face()
|
|
|
|
| 74 |
# face restoration
|
| 75 |
for cropped_face in face_helper.cropped_faces:
|
| 76 |
# prepare data
|