catch opencv import error to fail gracefully without opencv-contrib
This commit is contained in:
@@ -7,13 +7,13 @@ echo installing requirements...
|
||||
|
||||
if exist "%python_exec%" (
|
||||
echo Installing with ComfyUI Portable
|
||||
%python_exec% -s -m pip uninstall opencv-python opencv-contrib-python opencv-python-headless opencv-contrib-python-headless
|
||||
%python_exec% -s -m pip uninstall -y opencv-python opencv-contrib-python opencv-python-headless opencv-contrib-python-headless
|
||||
for /f "delims=" %%i in (%requirements_txt%) do (
|
||||
%python_exec% -s -m pip install "%%i"
|
||||
)
|
||||
) else (
|
||||
echo Installing with system Python
|
||||
pip uninstall opencv-python opencv-contrib-python opencv-python-headless opencv-contrib-python-headless
|
||||
pip uninstall -y opencv-python opencv-contrib-python opencv-python-headless opencv-contrib-python-headless
|
||||
for /f "delims=" %%i in (%requirements_txt%) do (
|
||||
pip install "%%i"
|
||||
)
|
||||
|
||||
@@ -5,9 +5,13 @@ import torch
|
||||
import torchvision.transforms
|
||||
import numpy as np
|
||||
import cv2
|
||||
from cv2.ximgproc import guidedFilter
|
||||
from pymatting import *
|
||||
|
||||
try:
|
||||
from cv2.ximgproc import guidedFilter
|
||||
except ImportError:
|
||||
print("\033[33mUnable to import guidedFilter, make sure you have only opencv-contrib-python or run the import_error_install.bat script\033[m")
|
||||
|
||||
|
||||
class AlphaClean:
|
||||
def __init__(self):
|
||||
|
||||
Reference in New Issue
Block a user