olivas/backend/app/models/analysis.py
DJP 3467dbcf03 Initial commit — OliVAS visual attention analysis platform
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>
2026-02-23 20:20:58 -05:00

39 lines
1.7 KiB
Python

import uuid
from datetime import datetime
from sqlalchemy import Float, ForeignKey, Integer, JSON, String, func
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.models.base import Base
class Analysis(Base):
__tablename__ = "analyses"
id: Mapped[str] = mapped_column(
String(36), primary_key=True, default=lambda: str(uuid.uuid4())
)
project_id: Mapped[str] = mapped_column(ForeignKey("projects.id"), index=True)
user_id: Mapped[str] = mapped_column(String(36), index=True)
name: Mapped[str] = mapped_column(String(255))
model_used: Mapped[str] = mapped_column(String(50), default="deepgaze_iie")
status: Mapped[str] = mapped_column(String(20), default="pending")
original_filename: Mapped[str] = mapped_column(String(255))
image_width: Mapped[int] = mapped_column(Integer)
image_height: Mapped[int] = mapped_column(Integer)
file_format: Mapped[str] = mapped_column(String(10))
storage_path: Mapped[str] = mapped_column(String(512))
gaze_sequence: Mapped[dict | None] = mapped_column(JSON, nullable=True)
hotspots: Mapped[dict | None] = mapped_column(JSON, nullable=True)
overall_score: Mapped[float | None] = mapped_column(Float, nullable=True)
ai_insights: Mapped[dict | None] = mapped_column(JSON, nullable=True)
ai_cost_usd: Mapped[float | None] = mapped_column(Float, nullable=True)
created_at: Mapped[datetime] = mapped_column(server_default=func.now())
project: Mapped["Project"] = relationship(back_populates="analyses") # noqa: F821
aois: Mapped[list["AOI"]] = relationship( # noqa: F821
back_populates="analysis", cascade="all, delete-orphan"
)