diff --git a/nodes.py b/nodes.py index 8875921..9df39db 100644 --- a/nodes.py +++ b/nodes.py @@ -61,14 +61,17 @@ class DownloadAndLoadSAM2Model: local_dir=download_path, local_dir_use_symlinks=False) - if "base" in model: - model_cfg_path = os.path.join(script_directory, "sam2_configs", "sam2_hiera_b+.yaml") - elif "large" in model: - model_cfg_path = os.path.join(script_directory, "sam2_configs", "sam2_hiera_l.yaml") - elif "small" in model: - model_cfg_path = os.path.join(script_directory, "sam2_configs", "sam2_hiera_s.yaml") - elif "tiny" in model: - model_cfg_path = os.path.join(script_directory, "sam2_configs", "sam2_hiera_t.yaml") + model_mapping = { + "base": "sam2_hiera_b+.yaml", + "large": "sam2_hiera_l.yaml", + "small": "sam2_hiera_s.yaml", + "tiny": "sam2_hiera_t.yaml" + } + + model_cfg_path = next( + (os.path.join(script_directory, "sam2_configs", cfg) for key, cfg in model_mapping.items() if key in model), + None + ) model =load_model(model_path, model_cfg_path, segmentor, dtype, device) diff --git a/readme.md b/readme.md index 3cff7a5..257832c 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,17 @@ # WORK IN PROGRESS -For testing only currently. \ No newline at end of file +For testing only currently. + +Functional, but needs better coordinate selector. + +For now mask postprocessing is disabled due to it needing cuda extension compilation. + +Models are automatically downloade from https://huggingface.co/Kijai/sam2-safetensors/tree/main + +to `ComfyUI/models/sam2` + + + +Original repo: + +https://github.com/facebookresearch/segment-anything-2 \ No newline at end of file