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)