Team Ai
Apppublic

DevelopmentT/background-remover

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
config.py49 linesDownload Raw Back to root
1"""2Application-wide configuration constants.3Centralised here so every module pulls from a single source of truth.4"""5 6import os7 8# ---------------------------------------------------------------------------9# Server10# ---------------------------------------------------------------------------11APP_TITLE = "AI Image Processing Server"12APP_VERSION = "2.0.0"13 14# ---------------------------------------------------------------------------15# File Upload Limits16# ---------------------------------------------------------------------------17MAX_FILE_SIZE: int = 5 * 1024 * 1024  # 5 MB18ALLOWED_IMAGE_TYPES: set[str] = {"image/png", "image/jpeg", "image/webp", "image/bmp", "image/tiff"}19 20# ---------------------------------------------------------------------------21# Background Removal22# ---------------------------------------------------------------------------23BG_REMOVAL_MODEL: str = "u2netp"24 25# ---------------------------------------------------------------------------26# OCR27# ---------------------------------------------------------------------------28OCR_LANGUAGES: list[str] = ["en"]29OCR_GPU: bool = os.getenv("OCR_GPU", "false").lower() == "true"30 31# ---------------------------------------------------------------------------32# Rate Limiting (in-memory, per-IP)33# ---------------------------------------------------------------------------34RATE_LIMIT_WINDOW: int = 60       # seconds35RATE_LIMIT_MAX_REQUESTS: int = 15 # per window36 37# ---------------------------------------------------------------------------38# Image Preprocessing39# ---------------------------------------------------------------------------40CLAHE_CLIP_LIMIT: float = 2.041CLAHE_TILE_GRID: tuple[int, int] = (8, 8)42MEDIAN_BLUR_KERNEL: int = 3       # must be odd43GAUSSIAN_BLUR_KERNEL: tuple[int, int] = (3, 3)44 45# ---------------------------------------------------------------------------46# WebSocket47# ---------------------------------------------------------------------------48WS_HEARTBEAT_INTERVAL: int = 30   # seconds49