mvi-ai-engine / train_all.py
Musombi's picture
Update train_all.py
d356932
import os
import sys
import torch
import gc
sys.path.insert(0, os.path.abspath("."))
from training.train_expertise import train as train_expertise
# Use relative path so it works inside Hugging Face Spaces
ARTIFACTS_DIR = "./artifacts"
os.makedirs(ARTIFACTS_DIR, exist_ok=True)
def main():
print("[INFO] Starting Expertise model training...")
try:
print("\n===== Training Expertise Classifier =====")
train_expertise(save_dir=ARTIFACTS_DIR) # ensure your train function saves here
print(f"[SUCCESS] Expertise model trained and saved → {os.path.abspath(ARTIFACTS_DIR)}")
except Exception as e:
print(f"[ERROR] Expertise training failed: {e}")
print("\n[INFO] Clearing cache and freeing memory...")
gc.collect()
if torch.cuda.is_available():
torch.cuda.empty_cache()
print("\n[INFO] Training run complete.")
if __name__ == "__main__":
main()