import os import subprocess import sys import platform def install_requirements(): # Only run once if getattr(sys, "_custom_node_deps_installed", False): return sys._custom_node_deps_installed = True try: import cv2 import torch import numpy import kornia import insightface import onnxruntime return except ModuleNotFoundError: pass print("[Custom Node] Installing missing dependencies...") py_ver = sys.version_info req_file = os.path.join(os.path.dirname(__file__), "requirements.txt") # Detect OS system_name = platform.system().lower() is_windows = system_name == "windows" is_linux = system_name == "linux" # Base requirements subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", req_file]) # -------------------------- # NumPy wheels by OS # -------------------------- numpy_url = None if is_windows and py_ver.major == 3 and py_ver.minor == 12: numpy_url = ( "https://download.pytorch.org/whl/" "numpy-1.26.3-cp312-cp312-win_amd64.whl" "#sha256=da4b0c6c699a0ad73c810736303f7fbae483bcb012e38d7eb06a5e3b432c981b" ) elif is_linux and py_ver.major == 3 and py_ver.minor == 12: numpy_url = ( "https://download.pytorch.org/whl/" "numpy-1.26.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl" "#sha256=5f24750ef94d56ce6e33e4019a8a4d68cfdb1ef661a52cdaee628a56d2437419" ) # -------------------------- # InsightFace wheels by OS # -------------------------- insightface_url = None # Windows wheels if is_windows: if py_ver.major == 3 and py_ver.minor == 12: insightface_url = ( "https://huggingface.co/hanamizuki-ai/insightface-releases/resolve/" "8be7c041a804350c6cbfaba3c4941949a7bad0a4/" "insightface-0.7.3-cp312-cp312-win_amd64.whl" ) elif py_ver.major == 3 and py_ver.minor == 13: insightface_url = ( "https://huggingface.co/MonsterMMORPG/Wan_GGUF/resolve/main/" "insightface-0.7.3-cp313-cp313-win_amd64.whl" ) # Linux wheels elif is_linux: if py_ver.major == 3 and py_ver.minor == 12: insightface_url = ( "https://huggingface.co/iwr-redmond/linux-wheels/resolve/main/" "insightface-0.7.3-cp312-cp312-linux_x86_64.whl" ) # Add this when you have a CP313 Linux wheel elif py_ver.major == 3 and py_ver.minor == 13: insightface_url = ( "https://huggingface.co/iwr-redmond/linux-wheels/resolve/main/" "insightface-0.7.3-cp312-cp312-linux_x86_64.whl" ) # -------------------------- # Install wheels # -------------------------- if insightface_url: subprocess.check_call([ sys.executable, "-m", "pip", "install", "--force-reinstall", insightface_url ]) if numpy_url: subprocess.check_call([ sys.executable, "-m", "pip", "install", "--force-reinstall", numpy_url ]) print("[Custom Node] Dependencies installed. Please restart ComfyUI.") raise SystemExit install_requirements() # ComfyUI exports sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) from .input_switch import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS __all__ = [ "NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS" ]