HaramGuard / backend /config.py
munals's picture
Upload 96 files
9c69d05 verified
"""
HaramGuard β€” Central Configuration
=====================================
Edit this file to tune thresholds without touching agent code.
"""
import os
# ── API Keys ─────────────────────────────────────────────────────────
GROQ_API_KEY = os.getenv('GROQ_API_KEY', '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')
ANTHROPIC_KEY = os.getenv('ANTHROPIC_KEY', 'YOUR_ANTHROPIC_KEY_HERE')
# ── Paths ─────────────────────────────────────────────────────────────
_HERE = os.path.dirname(os.path.abspath(__file__))
VIDEO_PATH = os.path.join(_HERE, 'hajj_multi_video_annotated.mp4')
DB_PATH = os.path.join(_HERE, 'outputs/hajjflow_rt.db')
MODEL_PATH = os.path.join(_HERE, 'crowdhuman_yolov8m_head.pt')
# ── 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 = os.path.join(_HERE, '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.20 # density_pct > 20% β†’ P1 (MEDIUM)
# ── API Server ─────────────────────────────────────────────────────────
API_PORT = 8000