From 19322e7fc8b4ba29fb67070bd83f96f0d2e76f85 Mon Sep 17 00:00:00 2001 From: Jan Minar Date: Wed, 2 Oct 2024 22:16:44 +0100 Subject: [PATCH] Fix paths for windows windows install has an extra subdirectory 'ComfyUI' in the path beats me --- utils/sam.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils/sam.py b/utils/sam.py index 2739b0f..38528b4 100644 --- a/utils/sam.py +++ b/utils/sam.py @@ -34,9 +34,12 @@ def load_sam_image_model( # 2. Check if the "models" and "models/sam2" directories exist models_dir = os.path.join(current_working_directory, "models") + if not os.path.exists(models_dir): + # We're probably on Windows + models_dir = os.path.join(current_working_directory, "ComfyUI", "models") sam2_dir = os.path.join(models_dir, "sam2") - if os.path.exists(models_dir): + if not os.path.exists(models_dir): print(f"'models' directory exists: {models_dir}", flush=True) else: print(f"'models' directory does not exist: {models_dir}", flush=True) @@ -52,7 +55,9 @@ def load_sam_image_model( else: print(f"'models/sam2/{checkpoint}' directory does not exist: {model_path}", flush=True) - model = build_sam2(config, model_path, device=device) + try: + model = build_sam2(config, model_path, device=device) + except: return SAM2ImagePredictor(sam_model=model)