Spaces:
Runtime error
Runtime error
ResearcherXman
commited on
Commit
•
d5449b8
1
Parent(s):
c7c986d
add sort
Browse files
app.py
CHANGED
@@ -197,6 +197,7 @@ def generate_image(face_image, pose_image, prompt, negative_prompt, style_name,
|
|
197 |
if len(face_info) == 0:
|
198 |
raise gr.Error(f"Cannot find any face in the image! Please upload another person image")
|
199 |
|
|
|
200 |
face_info = face_info[-1]
|
201 |
face_emb = face_info['embedding']
|
202 |
face_kps = draw_kps(convert_from_cv2_to_image(face_image_cv2), face_info['kps'])
|
|
|
197 |
if len(face_info) == 0:
|
198 |
raise gr.Error(f"Cannot find any face in the image! Please upload another person image")
|
199 |
|
200 |
+
face_info = sorted(face_info, key=lambda x:(x['bbox'][2]-x['bbox'][0])*x['bbox'][3]-x['bbox'][1])[-1] # only use the maximum face
|
201 |
face_info = face_info[-1]
|
202 |
face_emb = face_info['embedding']
|
203 |
face_kps = draw_kps(convert_from_cv2_to_image(face_image_cv2), face_info['kps'])
|