Spaces:
Sleeping
Sleeping
File size: 766 Bytes
5dbc6d8 3c25cfa 5dbc6d8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | """Pre-download every transformer model into the HF cache.
Run at Docker build time so the image ships with all weights baked in:
first request per service is instant even after container restarts
(Spaces free tier wipes runtime disk on every rebuild/wake).
"""
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from huggingface_hub import snapshot_download # noqa: E402
import config # noqa: E402
MODELS = [
config.WHISPER_MODEL,
config.SENTIMENT_MODEL,
config.QA_MODEL,
config.TEXTGEN_MODEL,
config.TRANSLATION_MODEL,
config.NER_MODEL,
]
for repo in MODELS:
print(f"[preload] {repo}", flush=True)
snapshot_download(repo)
print("[preload] all models cached", flush=True)
|