diff --git a/modules/processors/frame/face_swapper.py b/modules/processors/frame/face_swapper.py index ebc1f8e..065d93a 100644 --- a/modules/processors/frame/face_swapper.py +++ b/modules/processors/frame/face_swapper.py @@ -54,11 +54,11 @@ def pre_check() -> bool: logging.error(f"Failed to create directory {download_directory_path} due to permission error: {e}") return False - # Use the direct download URL from Hugging Face + # Use the direct download URL from Hugging Face (FP32 model for broad GPU compatibility) conditional_download( download_directory_path, [ - "https://huggingface.co/hacksider/deep-live-cam/resolve/main/inswapper_128_fp16.onnx" + "https://huggingface.co/hacksider/deep-live-cam/resolve/main/inswapper_128.onnx" ], ) return True @@ -85,9 +85,9 @@ def get_face_swapper() -> Any: with THREAD_LOCK: if FACE_SWAPPER is None: + # Use FP32 model by default for broad GPU compatibility. + # FP16 can produce NaN on GPUs without Tensor Cores (e.g. GTX 16xx). model_name = "inswapper_128.onnx" - if "CUDAExecutionProvider" in modules.globals.execution_providers: - model_name = "inswapper_128_fp16.onnx" model_path = os.path.join(models_dir, model_name) update_status(f"Loading face swapper model from: {model_path}", NAME) try: diff --git a/run.py b/run.py index c834ef5..f01b4ec 100644 --- a/run.py +++ b/run.py @@ -1,5 +1,20 @@ #!/usr/bin/env python3 +import os +import sys + +# Add the project root to PATH so bundled ffmpeg/ffprobe are found +project_root = os.path.dirname(os.path.abspath(__file__)) +os.environ["PATH"] = project_root + os.pathsep + os.environ.get("PATH", "") + +# Add NVIDIA CUDA DLL directories to PATH so onnxruntime-gpu can find them +nvidia_dir = os.path.join(project_root, "venv", "Lib", "site-packages", "nvidia") +if os.path.isdir(nvidia_dir): + for pkg in os.listdir(nvidia_dir): + bin_dir = os.path.join(nvidia_dir, pkg, "bin") + if os.path.isdir(bin_dir): + os.environ["PATH"] = bin_dir + os.pathsep + os.environ["PATH"] + # Import the tkinter fix to patch the ScreenChanged error import tkinter_fix