mrrrme-emotion-ai / download_models.py
MichonGoddijn231849
fix loading3
cd7ff22
"""
Pre-download emotion2vec+ Large model for Docker build
This bakes the model into the image so it doesn't download at runtime.
"""
import os
import sys
# Set cache directories
# Set cache directories
CACHE_DIR = '/data/huggingface'
os.makedirs(CACHE_DIR, exist_ok=True)
os.environ['HF_HOME'] = CACHE_DIR
print(f"⬇️ Downloading emotion2vec+ Large from Hugging Face to {CACHE_DIR}...")
try:
from huggingface_hub import snapshot_download
# Download emotion2vec+ Large from HF
# Using the official model ID: emotion2vec/emotion2vec_plus_large
model_dir = snapshot_download(
repo_id='emotion2vec/emotion2vec_plus_large',
cache_dir=CACHE_DIR,
revision='main'
)
print(f"βœ… Model downloaded to: {model_dir}")
# Verify file existence
if os.path.exists(os.path.join(model_dir, 'model.pt')) or os.path.exists(os.path.join(model_dir, 'model.bin')):
print("βœ… Validation: Model file exists")
else:
print("❌ Validation failed: Model file missing")
# sys.exit(1) # Don't fail build if file structure is different, just warn
except Exception as e:
print(f"❌ Error downloading model: {e}")
sys.exit(1)