HaramGuard / backend /config.py
adeem6's picture
Update backend/config.py
c87335b verified
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