July 2026 MLOps / Event-Driven Architecture / Computer Vision / NLP / LangGraph / Production ML
SafetyOps Copilot.
Event-driven safety-incident platform: Redis Streams pipeline, DistilBERT severity scoring on 273k real MSHA narratives, YOLOv8 PPE detection, and a LangGraph triage copilot.
Overview
An event-driven incident monitoring platform for industrial EHS teams, built as three independently deployable services (FastAPI API, Streamlit UI, background worker) connected by a Redis Streams message bus over shared Postgres. Free-text reports are scored for severity by a DistilBERT model fine-tuned on 273,000 real MSHA accident narratives (labels derived from regulatory outcome codes, not synthetic data), site photos are scored for PPE compliance by YOLOv8n, and a 5-node LangGraph state machine generates structured triage briefs — deterministic and fully testable without any LLM, with the LLM as an optional enhancement layer that fails silently back to the deterministic draft.
Highlights
- DistilBERT severity classifier trained on 273k real MSHA narratives — 0.78 macro-F1 vs 0.34 rule-based baseline (95% relative lift) and 0.88 high-severity recall (5.5x the baseline)
- YOLOv8n PPE compliance detection (mAP@0.5 ≈ 0.81) behind a wrapper normalizing three different label-scheme conventions into one score
- Redis Streams consumer groups with 3x exponential-backoff retry, dead-letter queue with replay, and idempotent processing keyed on stream message ID — safe under worker crash-restarts
- Graceful ML degradation: both models sit behind lazy imports so the full pipeline, tests, and CI run with zero ML dependencies installed — 36 tests pass without torch
- Evidently drift reports, Prometheus metrics on API and worker, and an 8-panel Grafana dashboard
- ~5,100 LOC across 124 files
Stack
Python · FastAPI · Redis Streams · PostgreSQL · SQLAlchemy · LangGraph · DistilBERT · YOLOv8 · Docker · Prometheus · Grafana · Evidently · MLflow · DVC · Streamlit