cubiq / ComfyUI_InstantID

Apache License 2.0
1.29k stars 72 forks source link

Cannot import module 'cv2.gapi.wip.draw' #42

Closed thinkingjimmy closed 8 months ago

thinkingjimmy commented 8 months ago

After installed the insightface, I get this error:

Torch version: 2.2.0+cu121

Traceback (most recent call last):
  File "D:\Program\ComfyUI\nodes.py", line 1887, 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 "D:\Program\ComfyUI\custom_nodes\ComfyUI_InstantID\__init__.py", line 1,
in <module>
    from .InstantID import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
  File "D:\Program\ComfyUI\custom_nodes\ComfyUI_InstantID\InstantID.py", line 7,
 in <module>
    import cv2
  File "C:\tools\Miniconda3\envs\comflowy\lib\site-packages\cv2\__init__.py", li
ne 181, in <module>
    bootstrap()
  File "C:\tools\Miniconda3\envs\comflowy\lib\site-packages\cv2\__init__.py", li
ne 175, in bootstrap
    if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
  File "C:\tools\Miniconda3\envs\comflowy\lib\site-packages\cv2\__init__.py", li
ne 28, in __load_extra_py_code_for_module
    py_module = importlib.import_module(module_name)
  File "C:\tools\Miniconda3\envs\comflowy\lib\importlib\__init__.py", line 126,
in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\tools\Miniconda3\envs\comflowy\lib\site-packages\cv2\typing\__init__.
py", line 156, in <module>
    Prim = _typing.Union[cv2.gapi.wip.draw.Text, cv2.gapi.wip.draw.Circle, cv2.g
api.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 D:\Program\ComfyUI\custom_nodes\ComfyUI_InstantID module for custo
m nodes: module 'cv2.gapi.wip.draw' has no attribute 'Text'
cubiq commented 8 months ago

it's an issue with cv2 what version of opencv-python do you have installed? try to upgrade it

thinkingjimmy commented 8 months ago

I have installed it , and upgraded it. But it still gives the same error

thinkingjimmy commented 8 months ago

i've solved my problem.

pip install opencv-python==4.7.0.72

thinkingjimmy commented 8 months ago

but I got a new error when run the workflow:

Error occurred when executing InstantIDFaceAnalysis:

File "D:\Program\ComfyUI\execution.py", line 152, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "D:\Program\ComfyUI\execution.py", line 82, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "D:\Program\ComfyUI\execution.py", line 75, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "D:\Program\ComfyUI\custom_nodes\ComfyUI_InstantID\InstantID.py", line 360, in load_insight_face
model = FaceAnalysis(name="antelopev2", root=INSIGHTFACE_DIR, providers=[provider + 'ExecutionProvider',]) # buffalo_l
File "C:\tools\Miniconda3\envs\comflowy\lib\site-packages\insightface\app\face_analysis.py", line 43, in __init__
assert 'detection' in self.models
thinkingjimmy commented 8 months ago

if i reinstall insightface, I will get the same error: "Cannot import module 'cv2.gapi.wip.draw'"

cubiq commented 8 months ago

that's another extension, you probably need to upgrade it

thinkingjimmy commented 8 months ago

I have solved my problem: 1) if you get this error: AttributeError: module 'cv2.gapi.wip.draw' has no attribute 'Text'

you need to pip install opencv-python==4.7.0.72

2) if you get this error: in init assert 'detection' in self.models

you need to check this folder: models/insightface/models/antelopev2/

and make sure you have file like 1k3d68.onnx in this folder. In my case, I founded that all of this files were in models/insightface/models/antelopev2/antelopev2

so i deleted second antelopev2 folder, and move all files in the first floder