Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
thinkingjimmy opened this issue Feb 22, 2024 · 7 comments
Closed

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

thinkingjimmy opened this issue Feb 22, 2024 · 7 comments

Comments

@thinkingjimmy
Copy link

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
Copy link
Owner

cubiq commented Feb 23, 2024

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

@thinkingjimmy
Copy link
Author

thinkingjimmy commented Feb 23, 2024

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

@thinkingjimmy
Copy link
Author

i've solved my problem.

pip install opencv-python==4.7.0.72

@thinkingjimmy
Copy link
Author

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
Copy link
Author

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

@cubiq
Copy link
Owner

cubiq commented Feb 23, 2024

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

@thinkingjimmy
Copy link
Author

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

  1. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants