diff --git a/utils.py b/utils.py index 5d1811a..5aae45c 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,15 @@ def insightface_loader(provider): except ImportError as e: raise Exception(e) - path = os.path.join(folder_paths.models_dir, "insightface") + if not folder_paths.folder_names_and_paths.get("insightface"): + path = os.path.join(folder_paths.models_dir, "insightface") + else: + 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