File size: 1,950 Bytes
bd2c5ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26d5d83
bd2c5ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
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"

    @property
    def max_image_size_bytes(self) -> int:
        """Get max image size in bytes."""
        return int(self.MAX_IMAGE_SIZE_MB * 1024 * 1024)

    @property
    def auraface_path(self) -> Path:
        """Get AuraFace model path."""
        return Path(self.AURAFACE_MODEL_DIR)

    @property
    def antispoof_path(self) -> Path:
        """Get anti-spoof model path."""
        return Path(self.ANTISPOOF_MODEL_DIR)


# Global settings instance
settings = Settings()