"""Model acquisition: download YuNet, copy reusable models from the old projects on this machine when present. Idempotent — safe to re-run.""" from __future__ import annotations import logging import shutil import urllib.request from pathlib import Path log = logging.getLogger(__name__) YUNET_URL = ("https://github.com/opencv/opencv_zoo/raw/main/models/" "face_detection_yunet/face_detection_yunet_2023mar.onnx") BUFFALO_SC_URL = ("https://github.com/deepinsight/insightface/releases/" "download/v0.7/buffalo_sc.zip") RECOGNIZERS = ["adaface_ir101.onnx", "adaface_ir50.onnx", "w600k_r50.onnx", "arcface_int8.onnx", "w600k_mbf.onnx", "arcface.onnx"] # Known locations of reusable models from the previous projects. _LEGACY_MODEL_DIRS = [ Path(r"D:\NEARLE\WOrking now\RTSP_16072025\pattern_reg\models"), ] BUFFALO_L_URL = ("https://github.com/deepinsight/insightface/releases/" "download/v0.7/buffalo_l.zip") # target filename -> legacy filename _COPY_MAP = { "arcface.onnx": "arcface.onnx", "age_deploy.prototxt": "age_deploy.prototxt", "age_net.caffemodel": "age_net.caffemodel", "gender_deploy.prototxt": "gender_deploy.prototxt", "gender_net.caffemodel": "gender_net.caffemodel", "emotion-ferplus-8.onnx": "emotion-ferplus-8.onnx", } def _fetch(url: str, dest: Path, label: str) -> None: """Download with progress on stdout the supervisor can read. On first run this is minutes of nothing: the API is not up yet, so the app cannot ask the engine what it is doing, and a shop PC that shows a stopped engine for five minutes after install looks broken. The supervisor watches for `download: