-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
84 lines (67 loc) · 3.69 KB
/
Copy pathconfig.py
File metadata and controls
84 lines (67 loc) · 3.69 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""
Configuration settings for License Plate Recognition Pipeline
"""
import os
# Performance mode: disabled — full accuracy pipeline with consensus voting
FAST_MODE = False
# Paths
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
MODEL_PATH = os.path.join(BASE_DIR, "best.pt")
MODEL_PATH_ONNX = os.path.join(BASE_DIR, "best.onnx")
MODEL_PATH_COREML = os.path.join(BASE_DIR, "best.mlpackage")
OUTPUT_DIR = os.path.join(BASE_DIR, "output")
TEST_IMAGES_DIR = os.path.join(BASE_DIR, "test_images")
# YOLO inference input size
YOLO_IMGSZ = 640
# Create directories if they don't exist
os.makedirs(OUTPUT_DIR, exist_ok=True)
os.makedirs(TEST_IMAGES_DIR, exist_ok=True)
# YOLO Detection settings
DETECTION_CONFIDENCE = 0.50 # Balanced — catches plates without picking up signboards
IOU_THRESHOLD = 0.45 # IoU threshold for NMS
# Bike / small plate settings
SMALL_PLATE_AREA_THRESHOLD = 15000 # px² – plates below this get extra padding
SMALL_PLATE_PADDING = 25 # Extra pixels around small/bike plates
IGNORE_BIKE_PLATES = False # Skip square/tall plates (bikes) and only detect cars
# DeepSeek OCR-2 settings
OCR_MODEL_NAME = "deepseek-ai/DeepSeek-OCR-2"
OCR_PROMPT = "<image>\nFree OCR. " # Prompt for clean text extraction
USE_FLASH_ATTENTION = True # Set to False if flash-attn not installed
# Processing settings
DEVICE = "cuda" # Use "cpu" if no GPU available
IMAGE_EXTENSIONS = [".jpg", ".jpeg", ".png", ".bmp", ".webp"]
# Video settings
VIDEO_EXTENSIONS = [".mp4", ".avi", ".mov", ".mkv"]
VIDEO_FRAME_SKIP = 1 # Process every frame for live — don't miss cars
# Tracking / confirmation settings (video_pipeline.py)
# Only output a plate if its track is stable across multiple sampled frames.
VIDEO_MIN_TRACK_READS = 1
# Require the best plate text to dominate OCR reads for that track.
# This helps avoid “valid but noisy” OCR where different valid plates appear
# across frames for the same vehicle.
# Set to 0 to effectively disable the stability gate.
VIDEO_MIN_PLATE_STABILITY_RATIO = 0.0 # best_key_freq / pool_len
# Filter confirmed tracks by YOLO detection confidence (reduces false positives).
VIDEO_MIN_DET_CONF = 0.3
# For each plate track, only vote using the last portion of reads (later
# frames are usually less blurry because the car is closer).
VIDEO_OCR_TAIL_RATIO = 0.6
# Prefer truly confident OCR when multiple valid-looking plates compete.
# (PaddleOCR rec_scores are typically in [0,1].)
VIDEO_MIN_OCR_CONF = 0.45
# OCR confidence weighting power in track voting.
VIDEO_OCR_CONF_POWER = 3.0
VIDEO_LATENCY_LOG = os.path.join(OUTPUT_DIR, "latency_report.json")
# Edge / Raspberry Pi settings
MAX_PENDING_OCR = 5 # Drop new OCR tasks when queue exceeds this (prevents lag on Pi)
# ──────────────────────────────────────────────────────────────────
# Night Mode — auto-applied when dark scenes are detected
# ──────────────────────────────────────────────────────────────────
NIGHT_BRIGHTNESS_THRESHOLD = 80 # mean(gray) below this → night mode
NIGHT_DARK_RATIO_THRESHOLD = 0.45 # fraction of pixels < 60 for night
NIGHT_DETECTION_CONFIDENCE = 0.25 # much lower — let temporal voting filter
NIGHT_MIN_DET_CONF = 0.20 # accept dimmer detections
NIGHT_MIN_OCR_CONF = 0.30 # accept noisier OCR
NIGHT_FRAME_SKIP = 1 # process every frame at night
NIGHT_CLAHE_CLIP = 5.0 # aggressive contrast boost
NIGHT_CHECK_INTERVAL = 10 # re-evaluate day/night every N frames