37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
"""Configuration and environment variables."""
|
|
|
|
import os
|
|
|
|
# Model configuration
|
|
MODEL_NAME = os.getenv("FACE_MODEL_NAME", "buffalo_l")
|
|
DET_SIZE = int(os.getenv("FACE_DET_SIZE", "1024"))
|
|
USE_TENSORRT = os.getenv("USE_TENSORRT", "true").lower() in ("true", "1", "yes")
|
|
|
|
# Image processing limits
|
|
MAX_DOWNLOAD_SIZE = int(os.getenv("MAX_DOWNLOAD_SIZE", 20 * 1024 * 1024)) # 20MB
|
|
MAX_IMAGE_DIMENSION = int(os.getenv("MAX_IMAGE_DIMENSION", 4096)) # 4096px (reduced from 8192)
|
|
MIN_IMAGE_DIMENSION = int(os.getenv("MIN_IMAGE_DIMENSION", 32)) # 32px
|
|
TARGET_MAX_DIMENSION = int(os.getenv("TARGET_MAX_DIMENSION", 2048)) # Downscale large images
|
|
|
|
# HTTP client settings
|
|
DOWNLOAD_TIMEOUT = float(os.getenv("DOWNLOAD_TIMEOUT", 15.0)) # 15 seconds
|
|
MAX_RETRIES = int(os.getenv("MAX_RETRIES", 3))
|
|
|
|
# HTTP connection pool settings
|
|
HTTP_POOL_MAX_CONNECTIONS = int(os.getenv("HTTP_POOL_MAX_CONNECTIONS", 100))
|
|
HTTP_POOL_MAX_KEEPALIVE = int(os.getenv("HTTP_POOL_MAX_KEEPALIVE", 20))
|
|
|
|
# Thread pool for blocking operations (GPU inference, image decode)
|
|
INFERENCE_THREADS = int(os.getenv("INFERENCE_THREADS", 4))
|
|
|
|
# TODO [PROD]: Add URL allowlist for SSRF protection
|
|
# ALLOWED_URL_PATTERNS = os.getenv("ALLOWED_URL_PATTERNS", "").split(",")
|
|
|
|
# TODO [PROD]: Add API key authentication
|
|
# API_KEY = os.getenv("API_KEY", "")
|
|
|
|
# TODO [PROD]: Add rate limiting configuration
|
|
# RATE_LIMIT_REQUESTS = int(os.getenv("RATE_LIMIT_REQUESTS", 100))
|
|
# RATE_LIMIT_WINDOW = int(os.getenv("RATE_LIMIT_WINDOW", 60))
|
|
|