fix: use MODELS_PATH env var for AI model paths instead of hardcoded /opt/models

The on-demand feature download system stores models at /data/ai/models/
(set via MODELS_PATH env var), but all Python scripts hardcoded
/opt/models/ as the base path. Each script now reads MODELS_PATH and
falls back to /opt/models for backward compatibility.
This commit is contained in:
ashim-hq
2026-04-18 10:17:01 +08:00
parent 28462c8f60
commit d7b6037b3d
9 changed files with 36 additions and 19 deletions
+5 -3
View File
@@ -26,21 +26,23 @@ def emit_progress(percent, stage):
print(json.dumps({"progress": percent, "stage": stage}), file=sys.stderr, flush=True)
_MODELS_BASE = os.environ.get("MODELS_PATH", "/opt/models")
GFPGAN_MODEL_PATH = os.environ.get(
"GFPGAN_MODEL_PATH",
"/opt/models/gfpgan/GFPGANv1.3.pth",
os.path.join(_MODELS_BASE, "gfpgan", "GFPGANv1.3.pth"),
)
CODEFORMER_MODEL_PATH = os.environ.get(
"CODEFORMER_MODEL_PATH",
"/opt/models/codeformer/codeformer.pth",
os.path.join(_MODELS_BASE, "codeformer", "codeformer.pth"),
)
# ── Model path for new mp.tasks API ─────────────────────────────────
_FACE_DETECT_MODEL_URL = "https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/latest/blaze_face_short_range.tflite"
_DOCKER_MODEL_PATH = "/opt/models/mediapipe/blaze_face_short_range.tflite"
_DOCKER_MODEL_PATH = os.path.join(_MODELS_BASE, "mediapipe", "blaze_face_short_range.tflite")
_LOCAL_MODEL_DIR = os.path.join(os.path.dirname(__file__), "..", "..", "..", ".models")
_LOCAL_MODEL_PATH = os.path.join(_LOCAL_MODEL_DIR, "blaze_face_short_range.tflite")