From 1d09d46f164803cbc468a86acb8534584dd3daa8 Mon Sep 17 00:00:00 2001 From: toto Date: Mon, 18 Dec 2023 16:08:37 +0800 Subject: [PATCH] update sim --- portrait/nodes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/portrait/nodes.py b/portrait/nodes.py index ed3c68e..fb0c1b0 100644 --- a/portrait/nodes.py +++ b/portrait/nodes.py @@ -494,7 +494,7 @@ class SimilarityPM: "main_image": ("IMAGE",), "compare_image": ("IMAGE",), "model": (["sim"],), - "result_prefix": ("STRING",) + "result_prefix": ("STRING",{"default": ""}), }, } @@ -507,9 +507,13 @@ class SimilarityPM: main_image_copy = tensor_to_img(main_image) compare_image_copy = tensor_to_img(compare_image) score = None + result = None if model == "sim": root_embedding = get_face_recognition()(dict(user=Image.fromarray(np.uint8(main_image_copy))))[OutputKeys.IMG_EMBEDDING] compare_embedding = get_face_recognition()(dict(user=Image.fromarray(np.uint8(compare_image_copy))))[OutputKeys.IMG_EMBEDDING] score = float(np.dot(root_embedding, np.transpose(compare_embedding))[0][0]) - result = f"{result_prefix}_{round(score, 2)}" + if result_prefix is "": + result = str(round(score, 2)) + else: + result = f"{result_prefix}_{round(score, 2)}" return (result,)