fofr / cog-comfyui

Run ComfyUI with an API
https://replicate.com/fofr/any-comfyui-workflow
MIT License
527 stars 116 forks source link

ComfyUI-Impact-Pack is missing dependencies #36

Closed Six6pounder closed 6 months ago

Six6pounder commented 8 months ago

Issue Report

Description

When running the script main.py in, the program encounters an unexpected behavior. I tried to install using pip install -r requirements.txt inside ComfyUI-Impact-Pack folder and also Python install.py but still the same error. I also ran ./scripts/clone_plugins.sh after cloning the repo

Steps to Reproduce

  1. Run the script main.py with the command python main.py --listen 0.0.0.0.

Expected Behavior

The script should run without any issues and provide the expected output.

Actual Behavior

The script encounters an issue during execution.

Environment

Running 'bash' in Docker with the current directory mounted as a volume...
root@c484976c6fd1:/src# cd ComfyUI/
root@c484976c6fd1:/src/ComfyUI# python main.py --listen 0.0.0.0
Total VRAM 9976 MB, total RAM 31820 MB
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 3080 : cudaMallocAsync
VAE dtype: torch.bfloat16
Using pytorch cross attention
[tinyterraNodes] Loaded
### Loading: ComfyUI-Inspire-Pack (V0.59)
------------------------------------------
Comfyroll Studio v1.76 :  175 Nodes Loaded
------------------------------------------
** For changes, please see patch notes at https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/blob/main/Patch_Notes.md
** For help, please see the wiki at https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki
------------------------------------------
Total VRAM 9976 MB, total RAM 31820 MB
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 3080 : cudaMallocAsync
VAE dtype: torch.bfloat16
[ReActor] - STATUS - Running v0.4.1-b9 in ComfyUI
Torch version: 2.2.1+cu121
FizzleDorf Custom Nodes: Loaded
### Loading: ComfyUI-Impact-Pack (V4.76.1)
### ComfyUI-Impact-Pack is missing dependencies
fofr commented 8 months ago

Can you find out which dependency is missing?

Try temporarily changing line 67 in ComfyUI/custom_nodes/ComfyUI-Impact-Pack/__init__.py

To:

except ImportError as e:
    missing_dependency = str(e).split("No module named ")[-1]
    print(f"### ComfyUI-Impact-Pack is missing dependency: {missing_dependency}")
    exit(1)
fofr commented 8 months ago

Also, if you aren't using ImpactPack, you could remove it.

Six6pounder commented 8 months ago

Can you find out which dependency is missing?

Try temporarily changing line 67 in ComfyUI/custom_nodes/ComfyUI-Impact-Pack/__init__.py

To:

except ImportError as e:
    missing_dependency = str(e).split("No module named ")[-1]
    print(f"### ComfyUI-Impact-Pack is missing dependency: {missing_dependency}")
    exit(1)

This is the output, sorry for the delay. I'm unsure if the Python exception triggered


### Loading: ComfyUI-Impact-Pack (V4.76.1)
Traceback (most recent call last):
File "/src/ComfyUI/nodes.py", line 1893, in load_custom_node
module_spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/src/ComfyUI/custom_nodes/ComfyUI-Impact-Pack/__init__.py", line 49, in <module>
import impact.subpack_nodes  # This import must be done before cv2.
File "/src/ComfyUI/custom_nodes/ComfyUI-Impact-Pack/impact_subpack/impact/subpack_nodes.py", line 3, in <module>
import impact.core as core
File "/src/ComfyUI/custom_nodes/ComfyUI-Impact-Pack/modules/impact/core.py", line 4, in <module>
from impact.utils import *
File "/src/ComfyUI/custom_nodes/ComfyUI-Impact-Pack/modules/impact/utils.py", line 3, in <module>
import cv2
File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/__init__.py", line 175, in bootstrap
if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/__init__.py", line 28, in __load_extra_py_code_for_module
py_module = importlib.import_module(module_name)
File "/root/.pyenv/versions/3.10.6/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/typing/__init__.py", line 156, in <module>
Prim = _typing.Union[cv2.gapi.wip.draw.Text, cv2.gapi.wip.draw.Circle, cv2.gapi.wip.draw.Image, cv2.gapi.wip.draw.Line, cv2.gapi.wip.draw.Rect, cv2.gapi.wip.draw.Mosaic, cv2.gapi.wip.draw.Poly]
AttributeError: module 'cv2.gapi.wip.draw' has no attribute 'Text'

Cannot import /src/ComfyUI/custom_nodes/ComfyUI-Impact-Pack module for custom nodes: module 'cv2.gapi.wip.draw' has no attribute 'Text' Efficiency Nodes: Attempting to add Control Net options to the 'HiRes-Fix Script' Node (comfyui_controlnet_aux add-on)...Failed! Efficiency Nodes: Attempting to add 'AnimatedDiff Script' Node (ComfyUI-AnimateDiff-Evolved add-on)...[AnimateDiffEvo] - ERROR - No motion models found. Please download one and place in: ['/src/ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/models', '/src/ComfyUI/models/animatediff_models'] Efficiency Nodes: Attempting to add 'AnimatedDiff Script' Node (ComfyUI-AnimateDiff-Evolved add-on)...Failed! Efficiency Nodes Warning: Failed to import python package 'simpleeval'; related nodes disabled.

[AnimateDiffEvo] - ERROR - No motion models found. Please download one and place in: ['/src/ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/models', '/src/ComfyUI/models/animatediff_models'] Traceback (most recent call last): File "/src/ComfyUI/nodes.py", line 1893, in load_custom_node module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/src/ComfyUI/custom_nodes/ComfyUI-VideoHelperSuite/init.py", line 1, in from .videohelpersuite.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS File "/src/ComfyUI/custom_nodes/ComfyUI-VideoHelperSuite/videohelpersuite/nodes.py", line 15, in from .load_video_nodes import LoadVideoUpload, LoadVideoPath File "/src/ComfyUI/custom_nodes/ComfyUI-VideoHelperSuite/videohelpersuite/load_video_nodes.py", line 5, in import cv2 File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 181, in bootstrap() File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 175, in bootstrap if __load_extra_py_code_for_module("cv2", submodule, DEBUG): File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 28, in load_extra_py_code_for_module py_module = importlib.import_module(module_name) File "/root/.pyenv/versions/3.10.6/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/typing/init__.py", line 93, in MatLike = _typing.Union[cv2.mat_wrapper.Mat, NumPyArrayGeneric] AttributeError: partially initialized module 'cv2' has no attribute 'mat_wrapper' (most likely due to a circular import)

Cannot import /src/ComfyUI/custom_nodes/ComfyUI-VideoHelperSuite module for custom nodes: partially initialized module 'cv2' has no attribute 'mat_wrapper' (most likely due to a circular import) Traceback (most recent call last): File "/src/ComfyUI/nodes.py", line 1893, in load_custom_node module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/src/ComfyUI/custom_nodes/comfyui_controlnet_aux/init.py", line 2, in from .utils import here, create_node_input_types File "/src/ComfyUI/custom_nodes/comfyui_controlnet_aux/utils.py", line 4, in import cv2 File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 181, in bootstrap() File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 175, in bootstrap if __load_extra_py_code_for_module("cv2", submodule, DEBUG): File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 28, in load_extra_py_code_for_module py_module = importlib.import_module(module_name) File "/root/.pyenv/versions/3.10.6/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/typing/init__.py", line 93, in MatLike = _typing.Union[cv2.mat_wrapper.Mat, NumPyArrayGeneric] AttributeError: partially initialized module 'cv2' has no attribute 'mat_wrapper' (most likely due to a circular import)

Cannot import /src/ComfyUI/custom_nodes/comfyui_controlnet_aux module for custom nodes: partially initialized module 'cv2' has no attribute 'mat_wrapper' (most likely due to a circular import) Traceback (most recent call last): File "/src/ComfyUI/nodes.py", line 1893, in load_custom_node module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/src/ComfyUI/custom_nodes/was-node-suite-comfyui/init.py", line 1, in from .WAS_Node_Suite import NODE_CLASS_MAPPINGS File "/src/ComfyUI/custom_nodes/was-node-suite-comfyui/WAS_Node_Suite.py", line 14105, in import cv2 File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 181, in bootstrap() File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 175, in bootstrap if __load_extra_py_code_for_module("cv2", submodule, DEBUG): File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 28, in load_extra_py_code_for_module py_module = importlib.import_module(module_name) File "/root/.pyenv/versions/3.10.6/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/typing/init__.py", line 93, in MatLike = _typing.Union[cv2.mat_wrapper.Mat, NumPyArrayGeneric] AttributeError: partially initialized module 'cv2' has no attribute 'mat_wrapper' (most likely due to a circular import)

Cannot import /src/ComfyUI/custom_nodes/was-node-suite-comfyui module for custom nodes: partially initialized module 'cv2' has no attribute 'mat_wrapper' (most likely due to a circular import) Traceback (most recent call last): File "/src/ComfyUI/nodes.py", line 1893, in load_custom_node module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/src/ComfyUI/custom_nodes/ComfyUI_InstantID/init.py", line 1, in from .InstantID import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS File "/src/ComfyUI/custom_nodes/ComfyUI_InstantID/InstantID.py", line 7, in import cv2 File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 181, in bootstrap() File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 175, in bootstrap if __load_extra_py_code_for_module("cv2", submodule, DEBUG): File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/init.py", line 28, in load_extra_py_code_for_module py_module = importlib.import_module(module_name) File "/root/.pyenv/versions/3.10.6/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/root/.pyenv/versions/3.10.6/lib/python3.10/site-packages/cv2/typing/init__.py", line 93, in MatLike = _typing.Union[cv2.mat_wrapper.Mat, NumPyArrayGeneric] AttributeError: partially initialized module 'cv2' has no attribute 'mat_wrapper' (most likely due to a circular import)

Cannot import /src/ComfyUI/custom_nodes/ComfyUI_InstantID module for custom nodes: partially initialized module 'cv2' has no attribute 'mat_wrapper' (most likely due to a circular import)

Import times for custom nodes: 0.0 seconds: /src/ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved 0.0 seconds: /src/ComfyUI/custom_nodes/ComfyUI-Logic 0.0 seconds: /src/ComfyUI/custom_nodes/masquerade-nodes-comfyui 0.0 seconds: /src/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus 0.0 seconds: /src/ComfyUI/custom_nodes/ComfyUI_UltimateSDUpscale 0.0 seconds (IMPORT FAILED): /src/ComfyUI/custom_nodes/comfyui_controlnet_aux 0.0 seconds: /src/ComfyUI/custom_nodes/ComfyUI-BRIA_AI-RMBG 0.0 seconds (IMPORT FAILED): /src/ComfyUI/custom_nodes/ComfyUI_InstantID 0.0 seconds (IMPORT FAILED): /src/ComfyUI/custom_nodes/ComfyUI-VideoHelperSuite 0.0 seconds: /src/ComfyUI/custom_nodes/ComfyUI-Custom-Scripts 0.0 seconds: /src/ComfyUI/custom_nodes/Derfuu_ComfyUI_ModdedNodes 0.0 seconds: /src/ComfyUI/custom_nodes/ComfyUI_tinyterraNodes 0.0 seconds: /src/ComfyUI/custom_nodes/ComfyUI-PhotoMaker 0.0 seconds: /src/ComfyUI/custom_nodes/ComfyUI-Advanced-ControlNet 0.0 seconds (IMPORT FAILED): /src/ComfyUI/custom_nodes/ComfyUI-Impact-Pack 0.0 seconds: /src/ComfyUI/custom_nodes/ComfyUI-Inspire-Pack 0.0 seconds: /src/ComfyUI/custom_nodes/ComfyUI_essentials 0.1 seconds: /src/ComfyUI/custom_nodes/efficiency-nodes-comfyui 0.6 seconds: /src/ComfyUI/custom_nodes/ComfyUI_FizzNodes 0.7 seconds: /src/ComfyUI/custom_nodes/ComfyUI_Comfyroll_CustomNodes 0.8 seconds (IMPORT FAILED): /src/ComfyUI/custom_nodes/was-node-suite-comfyui 1.0 seconds: /src/ComfyUI/custom_nodes/comfyui_segment_anything 1.1 seconds: /src/ComfyUI/custom_nodes/comfyui-reactor-node

Starting server

To see the GUI go to: http://0.0.0.0:8188

Six6pounder commented 8 months ago

Can you find out which dependency is missing?

Try temporarily changing line 67 in ComfyUI/custom_nodes/ComfyUI-Impact-Pack/__init__.py

To:

except ImportError as e:
    missing_dependency = str(e).split("No module named ")[-1]
    print(f"### ComfyUI-Impact-Pack is missing dependency: {missing_dependency}")
    exit(1)

I edited the code as:

except Exception as e:
    # import importlib
    # print("### ComfyUI-Impact-Pack: Reinstall dependencies (several dependencies are missing.)")
    # do_install()
    missing_dependency = str(e).split("No module named ")[-1]
    print(f"### ComfyUI-Impact-Pack is missing dependency: {missing_dependency}")
    exit(1)

and the output is:

### Loading: ComfyUI-Impact-Pack (V4.76.1)
### ComfyUI-Impact-Pack is missing dependency: module 'cv2.gapi.wip.draw' has no attribute 'Text'
fofr commented 8 months ago

It looks like it could be this: https://github.com/cubiq/ComfyUI_IPAdapter_plus/issues/251 https://github.com/Gourieff/comfyui-reactor-node#iv-controlnet-aux-node-import-failed-error-when-using-with-reactor-node

Try changing cog.yaml from:

-- opencv-python-headless>=4.0.1.24
+- opencv-python-headless>=4.9.0.80
Six6pounder commented 8 months ago

It looks like it could be this: cubiq/ComfyUI_IPAdapter_plus#251 https://github.com/Gourieff/comfyui-reactor-node#iv-controlnet-aux-node-import-failed-error-when-using-with-reactor-node

Try changing cog.yaml from:

-- opencv-python-headless>=4.0.1.24
+- opencv-python-headless>=4.9.0.80

Still the same output, just to be sure that I have the right opencv version installed I ran:

root@e94e1ff32d71:/src/ComfyUI# pip show opencv-python-headless          
Name: opencv-python-headless
Version: 4.9.0.80
Summary: Wrapper package for OpenCV python bindings.
Home-page: https://github.com/opencv/opencv-python
Author: 
Author-email: 
License: Apache 2.0
Location: /root/.pyenv/versions/3.10.6/lib/python3.10/site-packages
Requires: numpy, numpy, numpy, numpy
Required-by: albumentations
Six6pounder commented 8 months ago

pip install opencv-python==4.6.0.66 seems to have fixed that issue, now it runs correctly. No idea why it works with that specific version

Six6pounder commented 8 months ago

pip install opencv-python==4.6.0.66 seems to have fixed that issue, now it runs correctly. No idea why it works with that specific version

@fofr Sorry for all these messages, I should have tested before but I noticed it only works if inside the cog I remove and then reinstall with pip install opencv-python==4.6.0.66 otherwise I get the error I posted above, in the cog.yaml I have set the 4.6.0.66 version but it won't work until inside the docker I reinstall it. Also If I restart the cog machine I get the same error again. To make it work basically I have to: sudo cog run -p 8188 bash pip uninstall opencv-python pip install opencv-python==4.6.0.66

fofr commented 6 months ago

Closing this issue in a tidy up, feel free to reopen if you're still having issues.