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
675 stars 78 forks source link

Avoid installing dependencies on every run #54

Closed frantic closed 6 months ago

frantic commented 7 months ago

It looks like the install.py is imported from __init__.py, which means every time this plugin is loaded, it'll trigger a bunch of pip installs because ensure_package is called from the module's top level. At best, it just slows down ComfyUI start, at worst it messes up some dependencies.

This PR wraps the call to ensure_package() into Python's idiomatic way of making sure it's being executed as a script (vs required as a module). Alternatively, we could remove the from .install import * line from __init__.py.

Another option is to remove install.py altogether — ComfyUI-Manager already supports requirements.txt and it doesn't seem like this install.py does anything different.

julien-blanchon commented 7 months ago

Please merge that, this node is unusable without

julien-blanchon commented 7 months ago

Pleaseee !

xingren23 commented 6 months ago

This operation significantly slows down the startup time of ComfyUI.

frantic commented 6 months ago

Hey @storyicon, could you please let us know if you'd consider merging this in?

storyicon commented 6 months ago

lgtm, thanks for your PR

julien-blanchon commented 6 months ago

Let's GO !