-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
55 lines (42 loc) · 1.91 KB
/
config.py
File metadata and controls
55 lines (42 loc) · 1.91 KB
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
import os
from typing import Tuple
# --- Environment Setup (Must be first, before any TF/Keras imports) ---
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
# --- Logging ---
LOG_FORMAT = '[%(asctime)s] %(levelname)s - %(message)s'
# --- Paths ---
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
MODELS_DIR = os.path.join(BASE_DIR, "models")
MASK_MODEL_PATH = os.path.join(MODELS_DIR, "mask_detector.h5")
FACE_MODEL_YUNET = os.path.join(MODELS_DIR, "face_detection_yunet_2023mar.onnx")
# --- Camera Settings ---
CAMERA_INDEX: int = 0 # Webcam device index (0 = default)
CAMERA_WIDTH: int = 1280
CAMERA_HEIGHT: int = 720
# --- Inference Settings ---
INFERENCE_WIDTH: int = 640 # Frame width used for AI inference (smaller = faster)
MODEL_INPUT_SIZE: Tuple[int, int] = (224, 224) # MobileNetV2 input dimensions
BATCH_SIZE: int = 32 # Mask classifier batch size
# --- Detection Thresholds ---
CONFIDENCE_THRESHOLD: float = 0.5
# YuNet Face Detector Hyperparameters
YUNET_SCORE_THRESHOLD: float = 0.6
YUNET_NMS_THRESHOLD: float = 0.3
YUNET_TOP_K: int = 5000
# Minimum valid face bounding-box side (pixels, at inference resolution)
MIN_FACE_SIZE_PX: int = 10
# --- UI / Visual Settings ---
WINDOW_NAME: str = "Face Mask Detection"
# Semi-transparent overlay alpha (0.0 = transparent, 1.0 = opaque)
GLASS_ALPHA: float = 0.7
# Pixel offset between the face box and the floating pill label
PILL_FLOAT_OFFSET: int = 15
# FPS smoothing — rolling average window size
FPS_SMOOTHING_WINDOW: int = 10
# --- Color Palette (BGR) ---
COLOR_MASK: Tuple[int, int, int] = (113, 204, 46) # Emerald Green
COLOR_NO_MASK: Tuple[int, int, int] = (60, 76, 231) # Alizarin Red
COLOR_TEXT: Tuple[int, int, int] = (255, 255, 255) # Pure White
COLOR_GLASS_BG: Tuple[int, int, int] = (30, 30, 30) # Dark Glass
COLOR_UI_ACCENT: Tuple[int, int, int] = (240, 240, 240) # Off-White