Spaces:
Sleeping
Sleeping
| """ | |
| Configuration settings for KYC POC application. | |
| """ | |
| from pydantic_settings import BaseSettings | |
| from typing import List | |
| from pathlib import Path | |
| class Settings(BaseSettings): | |
| """Application settings.""" | |
| # Application | |
| APP_NAME: str = "KYC POC API" | |
| APP_VERSION: str = "1.0.0" | |
| DEBUG: bool = True | |
| # Model paths | |
| AURAFACE_MODEL_DIR: str = "insightface_models/models/auraface" | |
| ANTISPOOF_MODEL_DIR: str = "models/anti_spoof" | |
| SILENT_FACE_REPO_DIR: str = "Silent-Face-Anti-Spoofing" | |
| # Face matching | |
| FACE_MATCH_THRESHOLD: float = 0.5 | |
| # Liveness detection | |
| LIVENESS_THRESHOLD: float = 0.5 | |
| # Face quality thresholds | |
| BLUR_THRESHOLD: float = 100.0 # Below this = blurry | |
| BRIGHTNESS_MIN: float = 0.2 # Below this = too dark | |
| BRIGHTNESS_MAX: float = 0.8 # Above this = too bright | |
| POSE_MAX_YAW: float = 30.0 # Max yaw angle for frontal face | |
| POSE_MAX_PITCH: float = 30.0 # Max pitch angle for frontal face | |
| POSE_MAX_ROLL: float = 30.0 # Max roll angle for frontal face | |
| # Device settings | |
| USE_GPU: bool = False # CPU mode for POC | |
| DEVICE_ID: int = -1 # -1 for CPU, 0+ for GPU | |
| # API settings | |
| MAX_IMAGE_SIZE_MB: float = 10.0 | |
| ALLOWED_IMAGE_TYPES: List[str] = ["image/jpeg", "image/png", "image/jpg"] | |
| # Face detection settings | |
| DET_SIZE: tuple = (640, 640) # Detection input size | |
| class Config: | |
| env_file = ".env" | |
| env_file_encoding = "utf-8" | |
| def max_image_size_bytes(self) -> int: | |
| """Get max image size in bytes.""" | |
| return int(self.MAX_IMAGE_SIZE_MB * 1024 * 1024) | |
| def auraface_path(self) -> Path: | |
| """Get AuraFace model path.""" | |
| return Path(self.AURAFACE_MODEL_DIR) | |
| def antispoof_path(self) -> Path: | |
| """Get anti-spoof model path.""" | |
| return Path(self.ANTISPOOF_MODEL_DIR) | |
| # Global settings instance | |
| settings = Settings() | |