""" Configuration management for the FastAPI application. """ import os from typing import Optional from pydantic_settings import BaseSettings class Settings(BaseSettings): """Application settings.""" # API Configuration API_V1_STR: str = "/api/v1" PROJECT_NAME: str = "Seamo Species API" VERSION: str = "1.0.0" DESCRIPTION: str = "FastAPI-based species identification using YOLOv5" # Model Configuration MODEL_NAME: str = "marina-benthic-33k" MODEL_PATH: str = "models/marina-benthic-33k.pt" HUGGINGFACE_REPO: str = "seamo-ai/marina-species-v1" DEVICE: Optional[str] = None # Auto-detect if None # Inference Configuration DEFAULT_CONFIDENCE_THRESHOLD: float = 0.25 DEFAULT_IOU_THRESHOLD: float = 0.45 DEFAULT_IMAGE_SIZE: int = 720 MAX_IMAGE_SIZE: int = 1280 MIN_IMAGE_SIZE: int = 320 # File Upload Configuration MAX_FILE_SIZE: int = 10 * 1024 * 1024 # 10MB ALLOWED_EXTENSIONS: set = {".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".webp"} # Performance Configuration MODEL_CACHE_SIZE: int = 1 ENABLE_MODEL_WARMUP: bool = True # HuggingFace Configuration HF_HUB_OFFLINE: bool = os.getenv("HF_HUB_OFFLINE", "0") == "1" TRANSFORMERS_NO_ADVISORY_WARNINGS: bool = True # Server Configuration HOST: str = "0.0.0.0" PORT: int = 7860 # HuggingFace Spaces standard # Development Configuration DEBUG: bool = False class Config: env_file = ".env" case_sensitive = True extra = "ignore" # Global settings instance settings = Settings()