ComfyUI_LayerStyle: ImportError: cannot import name 'guidedFilter' from 'cv2.ximgproc'

This error is caused by incorrect version of the opencv-contrib-python package,or this package is overwriteen by other opencv packages.

Solution:

  • Close ComfyUI and open the terminal window in the plugin directory and execute the following command :
 ../../../python_embeded/python.exe -s -m pip uninstall -y opencv-python opencv-python-headless opencv-contrib-python-headless opencv-contrib-python
  • To avoid other plugins install opencv packages, you can install here first, also can skip this step:
../../../python_embeded/python.exe -s -m pip install opencv-python opencv-python-headless opencv-contrib-python-headless
  • Then install opencv-contrib-python, ensuring that it is the LAST ONE to be installed:
../../../python_embeded/python.exe -s -m pip install opencv-contrib-python
  • Restart ComfyUI.

About this issue

  • Original URL
  • State: open
  • Created 5 months ago
  • Reactions: 5
  • Comments: 33 (9 by maintainers)

Most upvoted comments

Fixed on the ReActor Node side https://github.com/Gourieff/comfyui-reactor-node/commit/b08d47588c0683b186dc9fd623e86bbeb5eb9dba All 3 nodes should work together correctly for now

This can also be caused by having multiple opencv packages installed simultaneously, eg opencv-python and opencv-contrib-python. If that happens, the only solution I’ve found is to uninstall anything except for opencv-contrib-python, because it includes everything in all the other variants. Unfortunately some custom node packs explicitly list requirements for opencv-python or opencv-python-headless, and when they get updated by the manager, it reinstalls “missing” dependencies, and then you have to go back and uninstall them again after it’s done. I wish there was a better solution but I haven’t found one yet.

Fixed on the ReActor Node side Gourieff/comfyui-reactor-node@b08d475 All 3 nodes should work together correctly for now

Thank you for your works.