Spaces:
Sleeping
Sleeping
Commit
·
5fd5d22
1
Parent(s):
e89dadb
Add debugging for face alignment to diagnose smile editing issues
Browse files
runners/simple_runner.py
CHANGED
|
@@ -77,8 +77,11 @@ def run_alignment(image_path):
|
|
| 77 |
import dlib
|
| 78 |
from scripts.align_all_parallel import align_face
|
| 79 |
|
|
|
|
| 80 |
predictor = dlib.shape_predictor("pretrained_models/shape_predictor_68_face_landmarks.dat")
|
|
|
|
| 81 |
aligned_image, unalign_dict = align_face(filepath=image_path, predictor=predictor)
|
|
|
|
| 82 |
return aligned_image, unalign_dict
|
| 83 |
|
| 84 |
|
|
@@ -163,11 +166,13 @@ class SimpleRunner:
|
|
| 163 |
aligned_image_pth = orig_img_pth
|
| 164 |
|
| 165 |
if align:
|
|
|
|
| 166 |
aligned_image, unalign_dict = run_alignment(orig_img_pth)
|
| 167 |
save_align_pth = save_pth.parents[0] / (save_pth.stem + "_aligned.jpg")
|
| 168 |
print(f"Save aligned image to {save_align_pth}")
|
| 169 |
aligned_image.convert('RGB').save(save_align_pth)
|
| 170 |
aligned_image_pth = save_align_pth
|
|
|
|
| 171 |
|
| 172 |
if use_mask and mask_path is None:
|
| 173 |
print("Prepearing mask")
|
|
|
|
| 77 |
import dlib
|
| 78 |
from scripts.align_all_parallel import align_face
|
| 79 |
|
| 80 |
+
print(f"Loading dlib shape predictor from: pretrained_models/shape_predictor_68_face_landmarks.dat")
|
| 81 |
predictor = dlib.shape_predictor("pretrained_models/shape_predictor_68_face_landmarks.dat")
|
| 82 |
+
print(f"Running face alignment on: {image_path}")
|
| 83 |
aligned_image, unalign_dict = align_face(filepath=image_path, predictor=predictor)
|
| 84 |
+
print(f"Face alignment completed successfully")
|
| 85 |
return aligned_image, unalign_dict
|
| 86 |
|
| 87 |
|
|
|
|
| 166 |
aligned_image_pth = orig_img_pth
|
| 167 |
|
| 168 |
if align:
|
| 169 |
+
print(f"Running face alignment on {orig_img_pth}")
|
| 170 |
aligned_image, unalign_dict = run_alignment(orig_img_pth)
|
| 171 |
save_align_pth = save_pth.parents[0] / (save_pth.stem + "_aligned.jpg")
|
| 172 |
print(f"Save aligned image to {save_align_pth}")
|
| 173 |
aligned_image.convert('RGB').save(save_align_pth)
|
| 174 |
aligned_image_pth = save_align_pth
|
| 175 |
+
print(f"Face alignment completed. Using aligned image: {aligned_image_pth}")
|
| 176 |
|
| 177 |
if use_mask and mask_path is None:
|
| 178 |
print("Prepearing mask")
|
scripts/align_all_parallel.py
CHANGED
|
@@ -60,6 +60,7 @@ def align_face(filepath, predictor):
|
|
| 60 |
"""
|
| 61 |
unalign_dict = {}
|
| 62 |
lm = get_landmark(filepath, predictor)
|
|
|
|
| 63 |
|
| 64 |
lm_chin = lm[0: 17] # left-right
|
| 65 |
lm_eyebrow_left = lm[17: 22] # left-right
|
|
|
|
| 60 |
"""
|
| 61 |
unalign_dict = {}
|
| 62 |
lm = get_landmark(filepath, predictor)
|
| 63 |
+
print(f"Detected {len(lm)} facial landmarks")
|
| 64 |
|
| 65 |
lm_chin = lm[0: 17] # left-right
|
| 66 |
lm_eyebrow_left = lm[17: 22] # left-right
|