storyicon / comfyui_segment_anything

Based on GroundingDino and SAM, use semantic strings to segment any element in an image. The comfyui version of sd-webui-segment-anything.
Apache License 2.0
530 stars 67 forks source link

Add support for extra_model_paths #31

Closed Anson2048 closed 6 months ago

Anson2048 commented 6 months ago

Add support for extra_model_paths

Description: This enhancement allows users to specify custom folder paths via the extra_model_paths configuration file.

Link: extra_model_paths.yaml.example

Usage Example(extra_model_paths.yaml):

a111:
   sams: models\sam
   grounding-dino: models\grounding-dino

Brief Explanation: When comfy starts up, it registers the extra_custom_paths before the nodes are loaded. As a result, we get a mapping with the user-provided paths and an empty set of extensions. As nodes load and register their paths, the user-provided path is subsequently replaced in the process.

storyicon commented 6 months ago

image

LGTM, thanks for your contribution. I've tested your changes, and I believe they can be merged. However, it may not work as expected since many other custom nodes are modifying folder_names_and_paths in a incorrect way, often leading to the invalidation of extra_model_paths.yaml