Spaces:
Runtime error
Runtime error
File size: 787 Bytes
aae629d a7b721e aae629d 9fad749 6b24d30 9fad749 aae629d ab69d6d aae629d 6b24d30 9fad749 ab69d6d 9fad749 1970c43 ab69d6d 1970c43 ab69d6d a7b721e 6b24d30 1970c43 a7b721e |
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 |
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"
)
# Root health check
@app.get("/")
def root():
return {"message": "👶 Hello from Mila-Wellnest Backend API"}
# Mount the /predict endpoint from routes.py
app.include_router(router)
# On startup: Train the model if no saved checkpoint exists
@app.on_event("startup")
async def startup_event():
checkpoint_path = "./data/best_model"
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()
|