hacksider/Deep-Live-Cam · critical · FileNotFoundError

Model file not found: {model_path}

Error message

Model file not found: {model_path}

What it means

FileNotFoundError raised in get_enhancer (modules/processors/frame/face_enhancer_gpen256.py) when the GPEN 256px ONNX model is still absent after an automatic download attempt. The loader first checks for the file, calls conditional_download(models_dir, [MODEL_URL]) if missing, then re-checks: if the download did not produce the file (network failure, unreachable URL, unwritable directory), it raises with the resolved path.

Source

Thrown at modules/processors/frame/face_enhancer_gpen256.py:62


def pre_start() -> bool:
    if not is_image(modules.globals.target_path) and not is_video(modules.globals.target_path):
        update_status("Select an image or video for target path.", NAME)
        return False
    return True


def get_enhancer() -> Any:
    global ENHANCER
    with THREAD_LOCK:
        if ENHANCER is None:
            model_path = os.path.join(models_dir, MODEL_FILE)
            if not os.path.exists(model_path):
                from modules.utilities import conditional_download
                conditional_download(models_dir, [MODEL_URL])
            if not os.path.exists(model_path):
                raise FileNotFoundError(f"Model file not found: {model_path}")
            print(f"{NAME}: Loading ONNX model from {model_path}")
            ENHANCER = create_onnx_session(model_path)
            warmup_session(ENHANCER)
            print(f"{NAME}: Model loaded successfully.")
    return ENHANCER


def enhance_face(temp_frame: Frame, face: Face) -> Frame:
    try:
        session = get_enhancer()
    except Exception as e:
        print(f"{NAME}: {e}")
        return temp_frame
    try:
        return enhance_face_onnx(temp_frame, face, session, INPUT_SIZE)
    except Exception as e:
        print(f"{NAME}: Error during face enhancement: {e}")
        return temp_frame

View on GitHub (pinned to 987f6b392b)

Solutions

  1. Manually download the model from MODEL_URL (inspect MODEL_URL at the top of face_enhancer_gpen256.py) and place it in the models directory, matching the exact MODEL_FILE name.
  2. Check network reachability of the model host and any proxy/firewall rules; retry with the environment that permits egress.
  3. Ensure the models directory exists and is writable (mkdir -p, fix ownership/permissions), and disk space is sufficient.
  4. If the URL is dead, get the file from the project's release/mirror and verify its filename equals MODEL_FILE.

Example fix

# before
# relying on auto-download in a network-restricted environment:
session = get_enhancer()

# after
# pre-seed the model so no download is needed at runtime:
# curl -L -o <models_dir>/<MODEL_FILE> <MODEL_URL>
session = get_enhancer()
Defensive patterns

Strategy: validation

Validate before calling

import os, urllib.request
model_path = os.path.join(models_dir, MODEL_FILE)  # MODEL_FILE from face_enhancer_gpen256
if not os.path.exists(model_path):
    os.makedirs(models_dir, exist_ok=True)
    urllib.request.urlretrieve(MODEL_URL, model_path)  # fail loudly here, not at runtime
session = get_enhancer()

Try / catch

try:
    session = get_enhancer()
except FileNotFoundError as e:
    raise SystemExit(
        f"Model download failed: {e}. Fetch {MODEL_URL} into {models_dir} manually."
    )

Prevention

When it happens

Trigger: Offline machine or blocked network so conditional_download fails silently or raises internally; MODEL_URL is dead/moved; the models directory does not exist or lacks write permission so the download cannot land; download completes but under a different filename than MODEL_FILE expects.

Common situations: Air-gapped or proxy-restricted environments where the model host is unreachable; CI containers without network egress; a re-uploaded/moved model hosting bucket; read-only mounts (e.g. container image layer) for the models dir; disk-full during download.

Related errors


AI-assisted analysis of hacksider/Deep-Live-Cam@987f6b392b (2026-08-14). Data as JSON: /api/errors/844542b8b026e29c. Report an issue: GitHub.