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

fix opencv-python handling to avoid conflict #461

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 22 additions & 30 deletions WAS_Node_Suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -14485,36 +14485,28 @@ def encode(self, clip, text, token_normalization, weight_interpretation, seed=0,
cstr('`CLIPTextEncode (BlenderNeko Advanced + NSP)` node enabled under `WAS Suite/Conditioning` menu.').msg.print()

# opencv-python-headless handling
if 'opencv-python' in packages() or 'opencv-python-headless' in packages():
try:
import cv2
build_info = ' '.join(cv2.getBuildInformation().split())
if "FFMPEG: YES" in build_info:
if was_config.__contains__('show_startup_junk'):
if was_config['show_startup_junk']:
cstr("OpenCV Python FFMPEG support is enabled").msg.print()
if was_config.__contains__('ffmpeg_bin_path'):
if was_config['ffmpeg_bin_path'] == "/path/to/ffmpeg":
cstr(f"`ffmpeg_bin_path` is not set in `{WAS_CONFIG_FILE}` config file. Will attempt to use system ffmpeg binaries if available.").warning.print()
else:
if was_config.__contains__('show_startup_junk'):
if was_config['show_startup_junk']:
cstr(f"`ffmpeg_bin_path` is set to: {was_config['ffmpeg_bin_path']}").msg.print()
else:
cstr(f"OpenCV Python FFMPEG support is not enabled\033[0m. OpenCV Python FFMPEG support, and FFMPEG binaries is required for video writing.").warning.print()
except ImportError:
cstr("OpenCV Python module cannot be found. Attempting install...").warning.print()
install_package(
package='opencv-python-headless[ffmpeg]',
uninstall_first=['opencv-python', 'opencv-python-headless[ffmpeg]']
)
try:
import cv2
cstr("OpenCV Python installed.").msg.print()
except ImportError:
cstr("OpenCV Python module still cannot be imported. There is a system conflict.").error.print()
else:
install_package('opencv-python-headless[ffmpeg]')
try:
import cv2
build_info = ' '.join(cv2.getBuildInformation().split())
if "FFMPEG: YES" in build_info:
if was_config.__contains__('show_startup_junk'):
if was_config['show_startup_junk']:
cstr("OpenCV Python FFMPEG support is enabled").msg.print()
if was_config.__contains__('ffmpeg_bin_path'):
if was_config['ffmpeg_bin_path'] == "/path/to/ffmpeg":
cstr(f"`ffmpeg_bin_path` is not set in `{WAS_CONFIG_FILE}` config file. Will attempt to use system ffmpeg binaries if available.").warning.print()
else:
if was_config.__contains__('show_startup_junk'):
if was_config['show_startup_junk']:
cstr(f"`ffmpeg_bin_path` is set to: {was_config['ffmpeg_bin_path']}").msg.print()
else:
cstr(f"OpenCV Python FFMPEG support is not enabled\033[0m. OpenCV Python FFMPEG support, and FFMPEG binaries is required for video writing.").warning.print()
except ImportError:
cstr("OpenCV Python module cannot be found. Attempting install...").warning.print()
install_package(
package='opencv-python-headless[ffmpeg]',
uninstall_first=['opencv-python', 'opencv-python-headless[ffmpeg]']
)
try:
import cv2
cstr("OpenCV Python installed.").msg.print()
Expand Down