mirror of
https://github.com/hacksider/Deep-Live-Cam.git
synced 2026-07-30 13:58:57 +02:00
fix: address PR review feedback — SystemExit, AUTO device, thread timing
- Catch SystemExit from add_openvino_libs_to_path() so a missing OpenVINO installation never causes a hard exit on Windows - Replace hard-coded GPU+FP16 with AUTO:GPU,NPU,CPU device priority, letting OpenVINO pick the best available accelerator - Extract shared OPENVINO_PROVIDER_CONFIG constant to avoid duplication between _onnx_enhancer and face_swapper - Defer thread-suggestion evaluation until after execution_providers is assigned, fixing a latent timing bug that affected OpenVINO, CUDA, and DML thread hints
This commit is contained in:
+7
-1
@@ -58,7 +58,7 @@ def parse_args() -> None:
|
||||
program.add_argument('--live-resizable', help='The live camera frame is resizable', dest='live_resizable', action='store_true', default=False)
|
||||
program.add_argument('--max-memory', help='maximum amount of RAM in GB', dest='max_memory', type=int, default=suggest_max_memory())
|
||||
program.add_argument('--execution-provider', help='execution provider', dest='execution_provider', default=[suggest_default_execution_provider()], choices=suggest_execution_providers(), nargs='+')
|
||||
program.add_argument('--execution-threads', help='number of execution threads', dest='execution_threads', type=int, default=suggest_execution_threads())
|
||||
program.add_argument('--execution-threads', help='number of execution threads', dest='execution_threads', type=int, default=None)
|
||||
program.add_argument('-v', '--version', action='version', version=f'{modules.metadata.name} {modules.metadata.version}')
|
||||
|
||||
# register deprecated args
|
||||
@@ -90,6 +90,12 @@ def parse_args() -> None:
|
||||
modules.globals.execution_threads = args.execution_threads
|
||||
modules.globals.lang = args.lang
|
||||
|
||||
# The argparse default (None) avoids evaluating suggest_execution_threads()
|
||||
# before providers are decoded, and deprecated-arg overrides above may
|
||||
# have already set execution_threads.
|
||||
if modules.globals.execution_threads is None:
|
||||
modules.globals.execution_threads = suggest_execution_threads()
|
||||
|
||||
#for ENHANCER tumblers:
|
||||
for enhancer_key in ('face_enhancer', 'face_enhancer_gpen256', 'face_enhancer_gpen512'):
|
||||
modules.globals.fp_ui[enhancer_key] = enhancer_key in args.frame_processor
|
||||
|
||||
@@ -20,6 +20,11 @@ IS_APPLE_SILICON = platform.system() == "Darwin" and platform.machine() == "arm6
|
||||
# Limit concurrent ONNX calls to avoid VRAM exhaustion on multi-face frames
|
||||
THREAD_SEMAPHORE = threading.Semaphore(min(max(1, (os.cpu_count() or 1)), 8))
|
||||
|
||||
# OpenVINO provider configuration.
|
||||
# AUTO:GPU,NPU,CPU lets OpenVINO try the best available device in priority
|
||||
# order (Intel GPU → NPU → CPU).
|
||||
OPENVINO_PROVIDER_CONFIG = ("OpenVINOExecutionProvider", {"device_type": "AUTO:GPU,NPU,CPU"})
|
||||
|
||||
|
||||
def build_provider_config(providers=None):
|
||||
"""Wrap raw provider name strings with optimised CUDA / CoreML options.
|
||||
@@ -51,13 +56,8 @@ def build_provider_config(providers=None):
|
||||
},
|
||||
))
|
||||
elif p == "OpenVINOExecutionProvider":
|
||||
# Prefer Intel GPU with FP16 precision when available.
|
||||
# NB: GPU_FP16 is deprecated since OpenVINO 2025.4 — use
|
||||
# device_type="GPU" + precision="FP16" instead.
|
||||
config.append((
|
||||
"OpenVINOExecutionProvider",
|
||||
{"device_type": "GPU", "precision": "FP16"},
|
||||
))
|
||||
# AUTO lets OpenVINO select the best device
|
||||
config.append(OPENVINO_PROVIDER_CONFIG)
|
||||
else:
|
||||
config.append(p)
|
||||
return config
|
||||
|
||||
@@ -271,10 +271,10 @@ def get_face_swapper() -> Any:
|
||||
# fastest on modern GPUs (Blackwell/sm_120).
|
||||
providers_config.append(p)
|
||||
elif p == "OpenVINOExecutionProvider":
|
||||
providers_config.append((
|
||||
"OpenVINOExecutionProvider",
|
||||
{"device_type": "GPU", "precision": "FP16"},
|
||||
))
|
||||
from modules.processors.frame._onnx_enhancer import (
|
||||
OPENVINO_PROVIDER_CONFIG,
|
||||
)
|
||||
providers_config.append(OPENVINO_PROVIDER_CONFIG)
|
||||
else:
|
||||
providers_config.append(p)
|
||||
FACE_SWAPPER = insightface.model_zoo.get_model(
|
||||
|
||||
@@ -39,7 +39,7 @@ if sys.platform == "win32":
|
||||
add_openvino_libs_to_path,
|
||||
)
|
||||
add_openvino_libs_to_path()
|
||||
except (ImportError, FileNotFoundError):
|
||||
except (ImportError, FileNotFoundError, SystemExit):
|
||||
pass # OpenVINO not installed — no-op
|
||||
|
||||
# On Linux, pre-load NVIDIA shared libraries (cuDNN, cuBLAS, nvrtc...) shipped
|
||||
|
||||
Reference in New Issue
Block a user