notRaphael's picture
Add config module
947c505 verified
"""
Video Intelligence Platform β€” Configuration
"""
import os
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class Config:
# ── Gemini API ──────────────────────────────────────────────
gemini_api_key: str = field(default_factory=lambda: os.environ.get("GEMINI_API_KEY", ""))
gemini_vision_model: str = "gemini-2.0-flash"
gemini_embedding_model: str = "text-embedding-004"
gemini_embedding_dim: int = 768
# ── SigLIP2 for frame embeddings ────────────────────────────
siglip_model: str = "google/siglip2-so400m-patch14-384"
siglip_embedding_dim: int = 1152
# ── Grounding DINO for attribute detection ──────────────────
grounding_dino_model: str = "IDEA-Research/grounding-dino-tiny"
detection_box_threshold: float = 0.35
detection_text_threshold: float = 0.25
# ── Frame extraction ────────────────────────────────────────
extract_fps: float = 1.0 # frames per second to extract
max_frames: int = 3600 # cap at 1hr @ 1fps
# ── Indexing ────────────────────────────────────────────────
db_path: str = "video_index.db" # SQLite path
faiss_visual_path: str = "visual_index.faiss"
faiss_caption_path: str = "caption_index.faiss"
# ── Search ──────────────────────────────────────────────────
top_k: int = 20
akinator_threshold: int = 10 # if results > this, start tree refinement
# ── Device ──────────────────────────────────────────────────
device: str = "cpu"
def validate(self):
if not self.gemini_api_key:
raise ValueError(
"GEMINI_API_KEY not set. Export it: export GEMINI_API_KEY='your-key'"
)