45 lines
918 B
Python
45 lines
918 B
Python
"""FastAPI application entry point."""
|
|
|
|
import logging
|
|
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from app.config import DET_SIZE, MODEL_NAME
|
|
from app.face import load_face_app
|
|
from app.routes import embed
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
logger = logging.getLogger("face_service")
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
"""Application lifespan handler - load models on startup."""
|
|
logger.info("Starting face service...")
|
|
load_face_app()
|
|
logger.info("Face service ready")
|
|
yield
|
|
logger.info("Shutting down face service...")
|
|
|
|
|
|
app = FastAPI(
|
|
title="Face Service",
|
|
version="1.0.0",
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(embed.router)
|
|
|
|
|
|
@app.get("/healthz")
|
|
def healthz():
|
|
"""Health check endpoint."""
|
|
return {
|
|
"status": "ok",
|
|
"model": MODEL_NAME,
|
|
"det_size": DET_SIZE,
|
|
}
|
|
|