Update handler.py
Browse files- handler.py +8 -2
handler.py
CHANGED
@@ -175,6 +175,12 @@ class EndpointHandler:
|
|
175 |
})
|
176 |
return face_info_list
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
def __call__(self, data):
|
179 |
|
180 |
def convert_from_cv2_to_image(img: np.ndarray) -> Image:
|
@@ -270,7 +276,7 @@ class EndpointHandler:
|
|
270 |
# Use the largest face detected
|
271 |
face_info = max(face_info_list, key=lambda x: (x["bbox"][2] - x["bbox"][0]) * (x["bbox"][3] - x["bbox"][1]))
|
272 |
face_emb = face_info["embedding"]
|
273 |
-
face_kps = draw_kps(convert_from_cv2_to_image(face_image_cv2), face_info["
|
274 |
img_controlnet = face_image
|
275 |
|
276 |
if pose_image:
|
@@ -286,7 +292,7 @@ class EndpointHandler:
|
|
286 |
|
287 |
face_info = max(face_info_list, key=lambda x: (x["bbox"][2] - x["bbox"][0]) * (x["bbox"][3] - x["bbox"][1]))
|
288 |
face_emb = face_info["embedding"]
|
289 |
-
face_kps = draw_kps(pose_image, face_info["
|
290 |
|
291 |
width, height = face_kps.size
|
292 |
|
|
|
175 |
})
|
176 |
return face_info_list
|
177 |
|
178 |
+
def get_face_embedding(self, image):
|
179 |
+
# Extract features for the face image region
|
180 |
+
# Implement the logic to extract face embeddings
|
181 |
+
# For now, returning a placeholder value
|
182 |
+
return np.random.rand(512) # Replace with actual embedding extraction logic
|
183 |
+
|
184 |
def __call__(self, data):
|
185 |
|
186 |
def convert_from_cv2_to_image(img: np.ndarray) -> Image:
|
|
|
276 |
# Use the largest face detected
|
277 |
face_info = max(face_info_list, key=lambda x: (x["bbox"][2] - x["bbox"][0]) * (x["bbox"][3] - x["bbox"][1]))
|
278 |
face_emb = face_info["embedding"]
|
279 |
+
face_kps = draw_kps(convert_from_cv2_to_image(face_image_cv2), face_info["bbox"])
|
280 |
img_controlnet = face_image
|
281 |
|
282 |
if pose_image:
|
|
|
292 |
|
293 |
face_info = max(face_info_list, key=lambda x: (x["bbox"][2] - x["bbox"][0]) * (x["bbox"][3] - x["bbox"][1]))
|
294 |
face_emb = face_info["embedding"]
|
295 |
+
face_kps = draw_kps(pose_image, face_info["bbox"])
|
296 |
|
297 |
width, height = face_kps.size
|
298 |
|