Spaces:
Sleeping
Sleeping
File size: 3,217 Bytes
f492127 d6dde3f f492127 d6dde3f f492127 d6dde3f f492127 d6dde3f f492127 d6dde3f f492127 d6dde3f f492127 d6dde3f f492127 d6dde3f | 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 85 86 87 88 89 90 | # HaramGuard β Agentic AI Crowd Management System
## π Folder Structure
```
HaramGuard/
β
βββ config.py β All thresholds & API keys (edit here only)
βββ pipeline.py β RealTimePipeline β orchestrates all agents
βββ dashboard.py β Streamlit dashboard entry point
βββ requirements.txt
β
βββ core/ β Shared infrastructure (no agent logic here)
β βββ __init__.py
β βββ models.py β FrameResult, RiskResult, Decision dataclasses
β βββ database.py β HajjFlowDB β SQLite (4 tables)
β
βββ agents/ β One file per agent
β βββ __init__.py
β βββ perception_agent.py β YOLO tracking + Guardrails GR1/GR2
β βββ risk_agent.py β Clip segmentation + sliding K-window density scoring
β βββ reflection_agent.py β Self-critique design pattern (Bias detection)
β βββ operations_agent.py β Event-driven playbook + rate-limit guardrail
β βββ coordinator_agent.py β openai/gpt-oss-120b + output validation guardrails GR-C1..5
β
βββ outputs/ β Auto-created at runtime
βββ hajjflow_rt.db β Main SQLite database
βββ plots/ β Saved charts
```
## π€ Agent Pipeline
```
Frame
β
βΌ
PerceptionAgent β FrameResult (YOLO detect + track)
β
βΌ
RiskAgent β RiskResult (clip segmentation + K-window density score)
β
βΌ
ReflectionAgent β reflection{} (bias check + correction)
β
βΌ
OperationsAgent β Decision (event-driven, P0/P1/P2)
β
βΌ
CoordinatorAgent β plan{} (openai/gpt-oss-120b action plan, all priorities)
β
βΌ
pipeline.state β Dashboard
```
## π‘οΈ Guardrails
| ID | Agent | Description |
|----|-------|-------------|
| GR1 | PerceptionAgent | Person count capped at 500 |
| GR2 | PerceptionAgent | Density score capped at 50 |
| GR3 | RiskAgent | Risk score clamped to [0, 1] (density_pct / 100) |
| GR3b | RiskAgent | level_changed suppressed during K-window warmup (first 17 frames per clip) |
| GR4 | OperationsAgent | P0 rate-limited (1 per 5 min per zone); resets on pipeline restart |
| GR-C1..5 | CoordinatorAgent | LLM output validation (fields, threat_level, confidence, score-level consistency, Arabic fallback) |
| RF1..3 | ReflectionAgent | Chronic LOW bias, rising trend ignored, count-risk mismatch |
## π Run Evaluation
```bash
python evaluation.py
```
Outputs:
- `outputs/plots/eval_perception.png` β PerceptionAgent charts
- `outputs/plots/eval_risk.png` β RiskAgent score trajectories
- `outputs/plots/eval_e2e.png` β End-to-end accuracy + throughput
- `outputs/eval/summary.json` β Final metrics summary
Rubric coverage:
- β
End-to-end performance metrics (Section 5)
- β
Component-level evaluation (Sections 1β4)
- β
Error analysis methodology (Section 6)
- β
Evidence of iterative improvement (Section 7)
## π Run Backend API
```bash
pip install -r requirements.txt
python api.py
``` |