Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -42,13 +42,13 @@ def predict(im1, im2):
|
|
42 |
if results2.multi_face_landmarks:
|
43 |
for face_landmarks in results2.multi_face_landmarks:
|
44 |
# get location of face detected
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
face2 = im2[top_y:bottom_y, top_x:bottom_x]
|
51 |
-
cv2.rectangle(im2, (
|
52 |
|
53 |
# Convert the tensor back to a PIL Image
|
54 |
face1 = transforms.ToPILImage()(face1)
|
|
|
42 |
if results2.multi_face_landmarks:
|
43 |
for face_landmarks in results2.multi_face_landmarks:
|
44 |
# get location of face detected
|
45 |
+
top_x2 = int(face_landmarks.landmark[234].x * img2_w)
|
46 |
+
top_y2 = int(face_landmarks.landmark[10].y * img2_h)
|
47 |
+
bottom_x2 = int(face_landmarks.landmark[454].x * img2_w)
|
48 |
+
bottom_y2 = int(face_landmarks.landmark[152].y * img2_h)
|
49 |
|
50 |
face2 = im2[top_y:bottom_y, top_x:bottom_x]
|
51 |
+
cv2.rectangle(im2, (top_x2, top_y2), (bottom_x2, bottom_y2), (0, 255, 0), 2)
|
52 |
|
53 |
# Convert the tensor back to a PIL Image
|
54 |
face1 = transforms.ToPILImage()(face1)
|