This commit is contained in:
kijai
2024-07-30 21:25:09 +03:00
parent 165bfef98b
commit 3e3eb5a2d1
2 changed files with 26 additions and 9 deletions
+11 -8
View File
@@ -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)
+15 -1
View File
@@ -1,3 +1,17 @@
# WORK IN PROGRESS
For testing only currently.
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