diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..4cd7197 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md index feb2247..ba6ed5b 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ face_image = load_image("./examples/yann-lecun_resize.jpg") # prepare face emb face_info = app.get(cv2.cvtColor(np.array(face_image), cv2.COLOR_RGB2BGR)) -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 +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 face_emb = face_info['embedding'] face_kps = draw_kps(face_image, face_info['kps']) diff --git a/gradio_demo/app-multicontrolnet.py b/gradio_demo/app-multicontrolnet.py index a3bc721..681a24f 100644 --- a/gradio_demo/app-multicontrolnet.py +++ b/gradio_demo/app-multicontrolnet.py @@ -357,12 +357,7 @@ def main(pretrained_model_name_or_path="wangqixun/YamerMIX_v8", enable_lcm_arg=F f"Unable to detect a face in the image. Please upload a different photo with a clear face." ) - 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 + 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 face_emb = face_info["embedding"] face_kps = draw_kps(convert_from_cv2_to_image(face_image_cv2), face_info["kps"]) img_controlnet = face_image diff --git a/gradio_demo/app.py b/gradio_demo/app.py index 91d9949..48cab7f 100644 --- a/gradio_demo/app.py +++ b/gradio_demo/app.py @@ -239,7 +239,7 @@ def main(pretrained_model_name_or_path="wangqixun/YamerMIX_v8", enable_lcm_arg=F if len(face_info) == 0: raise gr.Error(f"Cannot find any face in the image! Please upload another person image") - 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 + 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 face_emb = face_info['embedding'] face_kps = draw_kps(convert_from_cv2_to_image(face_image_cv2), face_info['kps']) diff --git a/infer.py b/infer.py index f979f13..a54a0b2 100644 --- a/infer.py +++ b/infer.py @@ -64,7 +64,7 @@ if __name__ == "__main__": face_image = resize_img(face_image) face_info = app.get(cv2.cvtColor(np.array(face_image), cv2.COLOR_RGB2BGR)) - 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 + 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 face_emb = face_info['embedding'] face_kps = draw_kps(face_image, face_info['kps']) diff --git a/infer_full.py b/infer_full.py index d0a1bb9..fe26b99 100644 --- a/infer_full.py +++ b/infer_full.py @@ -79,7 +79,7 @@ if __name__ == "__main__": face_image = resize_img(face_image) face_info = app.get(cv2.cvtColor(np.array(face_image), cv2.COLOR_RGB2BGR)) - 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 + 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 face_emb = face_info['embedding'] # use another reference image @@ -88,7 +88,7 @@ if __name__ == "__main__": face_info = app.get(cv2.cvtColor(np.array(pose_image), cv2.COLOR_RGB2BGR)) pose_image_cv2 = convert_from_image_to_cv2(pose_image) - 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 + 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 face_kps = draw_kps(pose_image, face_info['kps']) width, height = face_kps.size