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>
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
import aiofiles
|
|
|
|
from app.config import settings
|
|
|
|
|
|
class LocalStorage:
|
|
def __init__(self):
|
|
self.base_dir = Path(settings.UPLOAD_DIR)
|
|
self.base_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
def analysis_dir(self, analysis_id: str) -> Path:
|
|
path = self.base_dir / analysis_id
|
|
path.mkdir(parents=True, exist_ok=True)
|
|
return path
|
|
|
|
async def save_bytes(self, data: bytes, analysis_id: str, filename: str) -> str:
|
|
dir_path = self.analysis_dir(analysis_id)
|
|
file_path = dir_path / filename
|
|
async with aiofiles.open(file_path, "wb") as f:
|
|
await f.write(data)
|
|
return str(file_path)
|
|
|
|
async def load_bytes(self, analysis_id: str, filename: str) -> bytes:
|
|
file_path = self.analysis_dir(analysis_id) / filename
|
|
async with aiofiles.open(file_path, "rb") as f:
|
|
return await f.read()
|
|
|
|
def get_path(self, analysis_id: str, filename: str) -> Path:
|
|
return self.analysis_dir(analysis_id) / filename
|
|
|
|
def exists(self, analysis_id: str, filename: str) -> bool:
|
|
return (self.analysis_dir(analysis_id) / filename).exists()
|
|
|
|
async def delete_analysis(self, analysis_id: str) -> None:
|
|
import shutil
|
|
dir_path = self.base_dir / analysis_id
|
|
if dir_path.exists():
|
|
shutil.rmtree(dir_path)
|
|
|
|
|
|
storage = LocalStorage()
|