From 10bbbed218458b8a899aac2140ec738d8d716f05 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 25 Oct 2025 09:38:26 -0400 Subject: [PATCH] handle opencv variants Signed-off-by: Vladimir Mandic --- installer.py | 8 ++++++++ modules/loader.py | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/installer.py b/installer.py index a06d04868..a41254cf7 100644 --- a/installer.py +++ b/installer.py @@ -1261,6 +1261,13 @@ def install_pydantic(): reload('pydantic', '1.10.21') +def install_opencv(): + install('opencv-python-headless==4.12.0.88', ignore=True, quiet=True) + install('opencv-python==4.12.0.88', ignore=True, quiet=True) + install('opencv-contrib-python==4.12.0.88', ignore=True, quiet=True) + install('opencv-contrib-python-headless==4.12.0.88', ignore=True, quiet=True) + + def install_insightface(): install('git+https://github.com/deepinsight/insightface@29b6cd65aa0e9ae3b6602de3c52e9d8949c8ee86#subdirectory=python-package', 'insightface') # insightface==0.7.3 with patches if args.new: @@ -1329,6 +1336,7 @@ def install_requirements(): if not installed(line, quiet=True): _res = install(line) install_pydantic() + install_opencv() if args.profile: pr.disable() print_profile(pr, 'Requirements') diff --git a/modules/loader.py b/modules/loader.py index d540fbac9..be747c461 100644 --- a/modules/loader.py +++ b/modules/loader.py @@ -155,6 +155,9 @@ from PIL import Image # pylint: disable=W0611,C0411 timer.startup.record("pillow") +import cv2 # pylint: disable=W0611,C0411 +timer.startup.record("cv2") + class _tqdm_cls(): def __call__(self, *args, **kwargs): bar_format = 'Progress {rate_fmt}{postfix} {bar} {percentage:3.0f}% {n_fmt}/{total_fmt} {elapsed} {remaining} ' + '\x1b[38;5;71m' + '{desc}' + '\x1b[0m' @@ -225,4 +228,4 @@ class VersionString(str): # support both string and tuple for version check torch.__version__ = VersionString(torch.__version__) errors.log.info(f'Torch: torch=={torch.__version__} torchvision=={torchvision.__version__}') -errors.log.info(f'Packages: diffusers=={diffusers.__version__} transformers=={transformers.__version__} accelerate=={accelerate.__version__} gradio=={gradio.__version__} pydantic=={pydantic.__version__} numpy=={np.__version__}') +errors.log.info(f'Packages: diffusers=={diffusers.__version__} transformers=={transformers.__version__} accelerate=={accelerate.__version__} gradio=={gradio.__version__} pydantic=={pydantic.__version__} numpy=={np.__version__} cv2=={cv2.__version__}')