fix: use INSIGHTFACE_HOME env var for model persistence

Hardcoded root="~/.insightface" ignored the INSIGHTFACE_HOME env var,
causing Buffalo_L to download into the container on every run instead
of persisting to the mounted volume.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 22:56:47 +00:00
co-authored by Claude Sonnet 4.6
parent d106d30060
commit d7d0431a36
+3 -2
View File
@@ -92,7 +92,8 @@ def get_insightface_app():
# Suppress C-level output during model loading
with open(os.devnull, "w") as devnull, contextlib.redirect_stdout(devnull), contextlib.redirect_stderr(devnull):
_insightface_app = FaceAnalysis(name="buffalo_l", root="~/.insightface", providers=providers)
insightface_home = os.environ.get("INSIGHTFACE_HOME", os.path.expanduser("~/.insightface"))
_insightface_app = FaceAnalysis(name="buffalo_l", root=insightface_home, providers=providers)
_insightface_app.prepare(ctx_id=ctx_id, det_size=(640, 640))
return _insightface_app
@@ -108,7 +109,7 @@ def get_insightface_app():
try:
from insightface.app import FaceAnalysis
_insightface_app = FaceAnalysis(name="buffalo_l", root="~/.insightface")
_insightface_app = FaceAnalysis(name="buffalo_l", root=insightface_home)
_insightface_app.prepare(ctx_id=-1, det_size=(640, 640))
return _insightface_app
except Exception as ex: