Automated Action ab0e9b973a Implement tomato severity segmentation model API
- Set up FastAPI project structure with SQLite database
- Create database models for tomato images and severity classifications
- Implement image upload and processing endpoints
- Develop a segmentation model for tomato disease severity detection
- Add API endpoints for analysis and results retrieval
- Implement health check endpoint
- Set up Alembic for database migrations
- Update project documentation
2025-05-27 06:22:15 +00:00

47 lines
1.3 KiB
Python

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()