from pathlib import Path from typing import List from pydantic_settings import BaseSettings class Settings(BaseSettings): # Base settings PROJECT_NAME: str = "Tomato Severity Segmentation API" API_V1_STR: str = "/api" DEBUG: bool = True # CORS CORS_ORIGINS: List[str] = ["*"] # Paths BASE_DIR: Path = Path(__file__).resolve().parent.parent.parent STORAGE_DIR: Path = BASE_DIR / "storage" # Database DB_DIR: Path = STORAGE_DIR / "db" DB_DIR.mkdir(parents=True, exist_ok=True) SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite" # Image storage IMAGE_DIR: Path = STORAGE_DIR / "images" IMAGE_DIR.mkdir(parents=True, exist_ok=True) MAX_IMAGE_SIZE: int = 10 * 1024 * 1024 # 10MB ALLOWED_IMAGE_TYPES: List[str] = ["image/jpeg", "image/png"] # Model settings MODEL_DIR: Path = STORAGE_DIR / "models" MODEL_DIR.mkdir(parents=True, exist_ok=True) DEFAULT_MODEL_NAME: str = "tomato_severity_model" # Severity classifications SEVERITY_CLASSES: List[str] = [ "healthy", "early_blight", "late_blight", "bacterial_spot", "septoria_leaf_spot" ] class Config: env_file = ".env" case_sensitive = True settings = Settings()