File size: 3,437 Bytes
853d482
 
 
 
f492127
eb54c39
f492127
853d482
 
f492127
eb54c39
 
 
 
 
f492127
 
 
 
 
 
 
 
eb54c39
 
f492127
eb54c39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f492127
 
 
eb54c39
 
 
f492127
 
eb54c39
 
c87335b
f492127
 
 
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
import os

GROQ_API_KEY = os.environ.get("GROQ_API_KEY", "")

# ── Paths ─────────────────────────────────────────────────────────────
VIDEO_PATH = 'hajj_multi_video_annotated.mp4'
DB_PATH    = 'outputs/hajjflow_rt.db'
MODEL_PATH = 'crowdhuman_yolov8m_head.pt'
YOLO_CONFIG_DIR = '/tmp/Ultralytics'

# ── Cached Detection Mode ────────────────────────────────────────────
# When set, PerceptionAgent reads pre-computed detections from JSON
# instead of running YOLO live. Set to None to use live YOLO.
CACHED_DETECTIONS_PATH = 'cached_hajj_multi_video_detections.json'

# ── PerceptionAgent ───────────────────────────────────────────────────
PERCEPTION_MAX_PERSONS = 500
PERCEPTION_MAX_DENSITY = 50.0
PERCEPTION_CONF        = 0.12
PERCEPTION_IOU         = 0.5
PERCEPTION_IMGSZ       = 1024

# ── RiskAgent ─────────────────────────────────────────────────────────
# Risk is based on Fruin density computed from a K-window aggregate
# of unique track IDs per clip segment.
#
# Risk levels (density_pct):
#   HIGH   : density_pct > 80
#   MEDIUM : density_pct > 20
#   LOW    : density_pct <= 20
#
RISK_WINDOW_SIZE    = 30
RISK_HIGH_THRESHOLD = 150    # legacy β€” kept for reference
RISK_MED_THRESHOLD  = 30     # legacy β€” kept for reference
RISK_HIGH_DENSITY   = 1.0
RISK_HIGH_COUNT     = 100
RISK_EMA_ALPHA      = 0.6

# ── Clip segmentation ──────────────────────────────────────────────
CLIP_JUMP_THRESHOLD = 30     # legacy β€” kept for reference
CLIP_P_JUMP         = 40     # person count jump >= 40 β†’ boundary candidate
CLIP_D_JUMP         = 0.4    # density_score jump >= 0.4 β†’ boundary candidate
CLIP_MIN_LEN        = 10     # boundary must persist >= 10 frames (glitch filter)
CLIP_K_WINDOW       = 17     # aggregate window: union of unique IDs over K frames

# ── ReflectionAgent ───────────────────────────────────────────────────
REFLECTION_BIAS_WINDOW        = 10   # reduced: 17-frame loop, catch bias faster
REFLECTION_CROWD_LOW_THRESH   = 40   # chronic LOW suspicious above 40 persons
REFLECTION_HIGH_CROWD_THRESH  = 100  # 100+ persons but LOW β†’ upgrade to MEDIUM
REFLECTION_OVER_EST_THRESH    = 10   # HIGH risk but <10 persons β†’ downgrade

# ── OperationsAgent ───────────────────────────────────────────────────
OPS_RATE_LIMIT_SEC = 3       # minimal cooldown: LLM fires immediately on level change
OPS_P0_SCORE       = 0.80    # density_pct > 80% β†’ P0 (HIGH)
OPS_P1_SCORE       = 0.35    # aligns with MEDIUM threshold β€” score < 0.35 β†’ P2

# ── API Server ─────────────────────────────────────────────────────────
API_PORT = 8000