Estherrr777's picture
Update backend/app/main.py
6b24d30 verified
raw
history blame
779 Bytes
from fastapi import FastAPI
from .routes import router
import os
app = FastAPI(
title="Mila-Wellnest API",
description="Pregnancy Risk Prediction backend powered by fine-tuned DistilBERT.",
version="1.0.0"
)
@app.get("/")
def root():
return {"message": "👶 Hello from Mila-Wellnest Backend API"}
# Mount your prediction endpoint
app.include_router(router)
# Optional: Run training once on startup if model is missing
@app.on_event("startup")
async def startup_event():
checkpoint_path = "./data/best_model" # ✅ persistent path
if not os.path.exists(checkpoint_path):
os.makedirs(checkpoint_path, exist_ok=True)
print("⚙️ No checkpoint found. Starting training...")
from backend.app.train import train
train()