From f055b547a5ea1d0d51fdd33edc20e481e82f5bab Mon Sep 17 00:00:00 2001 From: xingren23 Date: Wed, 21 Feb 2024 10:46:14 +0800 Subject: [PATCH 1/2] load insightface from extra_model_path --- InstantID.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/InstantID.py b/InstantID.py index 3810f0f..6923792 100644 --- a/InstantID.py +++ b/InstantID.py @@ -21,7 +21,11 @@ current_paths, _ = folder_paths.folder_names_and_paths["instantid"] folder_paths.folder_names_and_paths["instantid"] = (current_paths, folder_paths.supported_pt_extensions) -INSIGHTFACE_DIR = os.path.join(folder_paths.models_dir, "insightface") +if "insightface" in folder_paths.folder_names_and_paths: + INSIGHTFACE_DIR = folder_paths.folder_names_and_paths["insightface"][0][0] +else: + INSIGHTFACE_DIR = os.path.join(folder_paths.models_dir, "insightface") + def draw_kps(image_pil, kps, color_list=[(255,0,0), (0,255,0), (0,0,255), (255,255,0), (255,0,255)]): stickwidth = 4 From 762042e6f7791f3db178eeaad60bff8415208ca1 Mon Sep 17 00:00:00 2001 From: xingren23 Date: Fri, 8 Mar 2024 20:34:08 +0800 Subject: [PATCH 2/2] import FaceInsight too slow, import only needed --- InstantID.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/InstantID.py b/InstantID.py index 602c51c..dcf8791 100644 --- a/InstantID.py +++ b/InstantID.py @@ -9,8 +9,6 @@ from comfy.ldm.modules.attention import optimized_attention from .resampler import Resampler -from insightface.app import FaceAnalysis - import torchvision.transforms.v2 as T import torch.nn.functional as F @@ -361,6 +359,7 @@ def INPUT_TYPES(s): CATEGORY = "InstantID" def load_insight_face(self, provider): + from insightface.app import FaceAnalysis model = FaceAnalysis(name="antelopev2", root=INSIGHTFACE_DIR, providers=[provider + 'ExecutionProvider',]) # buffalo_l model.prepare(ctx_id=0, det_size=(640, 640))