Full-stack application for predicting where humans look in images using DeepGaze saliency models. Includes heatmap overlays, gaze sequence prediction, hotspot detection, AOI analysis, rule-based insights, optional Claude AI design analysis, and professional PDF report generation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
import logging
|
|
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.api.router import api_router
|
|
from app.config import settings
|
|
|
|
logger = logging.getLogger("olivas")
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
# Startup: load ML models
|
|
logger.info(f"Starting OliVAS backend (device={settings.device})")
|
|
from app.services.saliency.model_manager import model_manager
|
|
|
|
try:
|
|
model_manager.load_models(device=settings.device)
|
|
logger.info(f"Models loaded: {list(model_manager.models.keys())}")
|
|
except Exception as e:
|
|
logger.warning(f"Failed to load ML models: {e}. Analysis will fail until models load.")
|
|
|
|
yield
|
|
|
|
# Shutdown
|
|
model_manager.cleanup()
|
|
logger.info("OliVAS backend shut down")
|
|
|
|
|
|
app = FastAPI(
|
|
title="OliVAS",
|
|
description="Open-Source Visual Attention Software by OLIVER",
|
|
version="0.1.0",
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins_list,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(api_router)
|