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
526 stars 66 forks source link

Fails to load #52

Open geoff-m opened 4 months ago

geoff-m commented 4 months ago

ComfyUI output during loading:

Traceback (most recent call last):
  File "S:\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1887, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "...\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_segment_anything\__init__.py", line 1, in <module>
    from .node import *
  File "...\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_segment_anything\node.py", line 17, in <module>
    from sam_hq.build_sam_hq import sam_model_registry
  File "...\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_segment_anything\sam_hq\build_sam_hq.py", line 13, in <module>
    from .modeling.tiny_vit import TinyViT
  File "...\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_segment_anything\sam_hq\modeling\tiny_vit.py", line 15, in <module>
    from timm.models.layers import DropPath as TimmDropPath,\
ModuleNotFoundError: No module named 'timm'

Cannot import ...\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_segment_anything module for custom nodes: No module named 'timm'
LukeG89 commented 4 months ago

Hi @geoff-m , I'm just a random person, but I can help you with your problem.

As I can see your ComfyUI path folder is really long. Try reducing it, I had problems having all that ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable my first time using Comfy. Maybe that is the cause of the problem. Try remove at least the first folder to have S:\ComfyUI_windows_portable. You can even rename it to S:\ComfyUI, shorter paths are always better.

This custom node is checking at every ComfyUI startup the requirements (I open myself an issue about that because is quite annoying), so it should automatically install the missing module timm. Maybe it didn't work because of the long path.

If reducing the path didn't fix the problem, you can install that specific missing module by opening the terminal from the main ComfyUI folder and using this script to install it:

python_embeded/python.exe -m pip install timm

Or to install all the requirements (edit the path if needed):

python_embeded/python.exe -s -m pip install -r S:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_segment_anything\requirements.txt

I hope I helped you with your issue!