Spaces:
Runtime error
Runtime error
Update backend/app/main.py
Browse files- backend/app/main.py +4 -3
backend/app/main.py
CHANGED
@@ -8,17 +8,18 @@ app = FastAPI(
|
|
8 |
version="1.0.0"
|
9 |
)
|
10 |
|
|
|
11 |
@app.get("/")
|
12 |
def root():
|
13 |
return {"message": "👶 Hello from Mila-Wellnest Backend API"}
|
14 |
|
15 |
-
# Mount
|
16 |
app.include_router(router)
|
17 |
|
18 |
-
#
|
19 |
@app.on_event("startup")
|
20 |
async def startup_event():
|
21 |
-
checkpoint_path = "./data/best_model"
|
22 |
if not os.path.exists(checkpoint_path):
|
23 |
os.makedirs(checkpoint_path, exist_ok=True)
|
24 |
print("⚙️ No checkpoint found. Starting training...")
|
|
|
8 |
version="1.0.0"
|
9 |
)
|
10 |
|
11 |
+
# Root health check
|
12 |
@app.get("/")
|
13 |
def root():
|
14 |
return {"message": "👶 Hello from Mila-Wellnest Backend API"}
|
15 |
|
16 |
+
# Mount the /predict endpoint from routes.py
|
17 |
app.include_router(router)
|
18 |
|
19 |
+
# On startup: Train the model if no saved checkpoint exists
|
20 |
@app.on_event("startup")
|
21 |
async def startup_event():
|
22 |
+
checkpoint_path = "./data/best_model"
|
23 |
if not os.path.exists(checkpoint_path):
|
24 |
os.makedirs(checkpoint_path, exist_ok=True)
|
25 |
print("⚙️ No checkpoint found. Starting training...")
|