Spaces:
Runtime error
Runtime error
Upload 4 files
Browse files- overlay.py +3 -3
overlay.py
CHANGED
|
@@ -3,7 +3,7 @@ from PIL import Image
|
|
| 3 |
import mediapipe as mp
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
from segmentation import
|
| 7 |
|
| 8 |
# MediaPipe Face Detection
|
| 9 |
mp_fd = mp.solutions.face_detection.FaceDetection(model_selection=1,
|
|
@@ -182,7 +182,7 @@ def overlay_source(background: Image.Image, source: Image.Image):
|
|
| 182 |
)
|
| 183 |
|
| 184 |
# Step 2: Get face from background (with forehead) and overlay onto scaled source
|
| 185 |
-
bg_face =
|
| 186 |
|
| 187 |
# Compute offset to align background face onto scaled source face
|
| 188 |
offset = compute_offset_to_align_faces(bbox_src_scaled, bbox_bg, 1.0)
|
|
@@ -197,7 +197,7 @@ def overlay_source(background: Image.Image, source: Image.Image):
|
|
| 197 |
print("✅ Overlaid background face onto scaled source")
|
| 198 |
|
| 199 |
# Step 3: Extract hair+face+forehead from the result
|
| 200 |
-
hair_face_result =
|
| 201 |
|
| 202 |
# Overlay this onto original background with smoothing -> temp variable
|
| 203 |
bbox_result = get_face_bbox(source_with_bg_face)
|
|
|
|
| 3 |
import mediapipe as mp
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
from segmentation import get_face, extract_hair
|
| 7 |
|
| 8 |
# MediaPipe Face Detection
|
| 9 |
mp_fd = mp.solutions.face_detection.FaceDetection(model_selection=1,
|
|
|
|
| 182 |
)
|
| 183 |
|
| 184 |
# Step 2: Get face from background (with forehead) and overlay onto scaled source
|
| 185 |
+
bg_face = get_face(background) # Extract face with forehead
|
| 186 |
|
| 187 |
# Compute offset to align background face onto scaled source face
|
| 188 |
offset = compute_offset_to_align_faces(bbox_src_scaled, bbox_bg, 1.0)
|
|
|
|
| 197 |
print("✅ Overlaid background face onto scaled source")
|
| 198 |
|
| 199 |
# Step 3: Extract hair+face+forehead from the result
|
| 200 |
+
hair_face_result = get_face(source_with_bg_face)
|
| 201 |
|
| 202 |
# Overlay this onto original background with smoothing -> temp variable
|
| 203 |
bbox_result = get_face_bbox(source_with_bg_face)
|