From 1132f4602c74bdb7022b6d133b6fba0c7dd9bd16 Mon Sep 17 00:00:00 2001 From: Guillaume Faguet Date: Fri, 26 Apr 2024 09:07:42 +0200 Subject: [PATCH 1/3] allow loading insightface model from extra paths --- utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 5d1811a..e608105 100644 --- a/utils.py +++ b/utils.py @@ -9,6 +9,7 @@ import torchvision.transforms.v2 as T except ImportError: import torchvision.transforms as T +import logging def get_clipvision_file(preset): preset = preset.lower() @@ -149,7 +150,14 @@ def insightface_loader(provider): except ImportError as e: raise Exception(e) - path = os.path.join(folder_paths.models_dir, "insightface") + folders_insightface=folder_paths.get_folder_paths("insightface") + if not folders_insightface: + path = os.path.join(folder_paths.models_dir, "insightface") + elif len(folders_insightface)>1: + logging.info(f"several insightface folders exist in extra_model_paths.yaml file. Using {folders_insightface[0]}") + path=folders_insightface[0] + else: + path=folders_insightface[0] model = FaceAnalysis(name="buffalo_l", root=path, providers=[provider + 'ExecutionProvider',]) model.prepare(ctx_id=0, det_size=(640, 640)) return model From d582b9505a573e506122b3400fa1b86628b7fb61 Mon Sep 17 00:00:00 2001 From: Guillaume Faguet Date: Sat, 27 Apr 2024 08:33:52 +0200 Subject: [PATCH 2/3] Edited logging info message --- utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.py b/utils.py index e608105..d4587ae 100644 --- a/utils.py +++ b/utils.py @@ -154,7 +154,7 @@ def insightface_loader(provider): if not folders_insightface: path = os.path.join(folder_paths.models_dir, "insightface") elif len(folders_insightface)>1: - logging.info(f"several insightface folders exist in extra_model_paths.yaml file. Using {folders_insightface[0]}") + logging.info(f"[IP ADAPTER PLUS] Several insightface folders exist in extra_model_paths.yaml file. Using {folders_insightface[0]}") path=folders_insightface[0] else: path=folders_insightface[0] From e1077f6a4e8f68c566f0cbc0acd7084f61ea5249 Mon Sep 17 00:00:00 2001 From: Guillaume Faguet Date: Sat, 27 Apr 2024 08:48:29 +0200 Subject: [PATCH 3/3] Handling case key doesn't exist in folder_path dict --- utils.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/utils.py b/utils.py index d4587ae..5aae45c 100644 --- a/utils.py +++ b/utils.py @@ -150,14 +150,15 @@ def insightface_loader(provider): except ImportError as e: raise Exception(e) - folders_insightface=folder_paths.get_folder_paths("insightface") - if not folders_insightface: + if not folder_paths.folder_names_and_paths.get("insightface"): path = os.path.join(folder_paths.models_dir, "insightface") - elif len(folders_insightface)>1: - logging.info(f"[IP ADAPTER PLUS] Several insightface folders exist in extra_model_paths.yaml file. Using {folders_insightface[0]}") - path=folders_insightface[0] else: - path=folders_insightface[0] + folders_insightface=folder_paths.get_folder_paths("insightface") + if len(folders_insightface)>1: + logging.info(f"[IP ADAPTER PLUS] Several insightface folders exist in extra_model_paths.yaml file. Using {folders_insightface[0]}") + path=folders_insightface[0] + else: + path=folders_insightface[0] model = FaceAnalysis(name="buffalo_l", root=path, providers=[provider + 'ExecutionProvider',]) model.prepare(ctx_id=0, det_size=(640, 640)) return model