Video analyticsStreamlit app · CLIAGPL-3.0

PPE Compliance VLM

Checks personal protective equipment on every worker in a video. Each person is tracked and re-identified, every hardhat, vest, glove, goggle and mask is matched to its wearer, and a 3-second majority vote turns a worker red only when the evidence holds. At the end, a vision-language model writes a one-line report for each worker with a confirmed violation.

The Streamlit app end to end: choose the infractions, upload a video, watch the live feed and read the VLM report cards. Recorded on a laptop CPU; processing and the VLM step are sped up. Footage: Pexels.
majority vote before a worker turns red
3 s
infraction types to choose from
7
PPE detectors to choose from
2
VLM sentence per flagged worker
1

01From detections to a decision per worker

Two detectors run on every frame: one finds the people, the other finds PPE items as worn or missing. Each item is assigned to the person whose box it overlaps, so the system reasons per worker instead of per box. Re-identification keeps the same id when someone leaves and comes back.

01 Video frame upload in the app or headless CLI 02 Person YOLO yolov8n + ByteTrack one id per worker 03 Re-ID HSV appearance gallery per person 04 PPE YOLO SafetyVision v8s or CHD YOLO26-L 05 Temporal vote 3 s window ≥ 60% majority 06 Reports + VLM per-person card SmolVLM / Idefics2
Fig. 01 · Processing pipeline, from the frame to the per-worker report

Single frames are noisy, so a worker's box never follows them directly. For each PPE item the last 3 seconds are read as worn, missing or unknown, and the state only changes when 60% of the informative frames agree; unknown frames never flip it.

CHECKING gray, first 3 s OK green box VIOLATION red, item listed ≥ 60% worn over 3 s ≥ 60% missing over 3 s ≥ 60% worn again ≥ 60% missing
Fig. 02 · Per-worker, per-item state with the default thresholds
Association
A PPE box belongs to the person it overlaps most (intersection over the smaller box ≥ 0.05).
Re-identification
A new track is compared with every person seen before by appearance; a match above 0.85 keeps the old id.
Consolidation
Reports only include workers seen at least 3 times with the violation in at least 10% of their frames.

02What it finds on real job-site footage

On a six-clip compilation of construction sites, carpenters, a warehouse and an industrial structure (about 83 s), the default SafetyVision model confirmed these violations:

NO-Safety Vest 16 NO-Hardhat 5 NO-Goggles 3
Fig. 03 · Workers with a confirmed violation, by type, on the six-clip compilation
2 s · everyone gray while checking
2 s · everyone gray while checking
6 s · green for PPE worn, red for missing
6 s · green for PPE worn, red for missing
10 s · decisions held by the vote
10 s · decisions held by the vote
ClipConfirmed violations
Construction siteNO-Safety Vest, NO-Hardhat
Industrial structureNO-Safety Vest, NO-Goggles
CarpentersNO-Safety Vest
Warehouse aisleNO-Safety Vest, NO-Hardhat, NO-Goggles
Compliant workernone: hardhat and vest stay green

Footage: Pexels clips listed in the repository. VLM answers are model outputs, so the report cards are meant for a human reviewer.

VLM double-check

In this rendered demo the video freezes the first time a worker is confirmed as a violation: the crop is enlarged, SmolVLM-500M runs on it on the CPU, and its answer is shown before playback resumes.

Built with scripts/make_demo_video.py; the real VLM time is shown on screen and the wait is shortened.

03Three steps to try it

install
git clone https://github.com/karemdm/ppe-compliance-vlm.git
cd ppe-compliance-vlm
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
Streamlit app
ppe-compliance --vlm-model HuggingFaceTB/SmolVLM-500M-Instruct
headless report
ppe-compliance analyze --input samples/construction_site.mp4 --output outputs/report.json --save-video outputs/construction_site.mp4 --no-vlm

04Why it is built this way

A vote, not a frame

PPE detectors flicker. A 3-second majority with hysteresis removes the blinking red boxes that make per-frame systems unusable on a monitor.

People first

Matching PPE to the person who wears it gives one decision per worker and one report per worker, which is what a safety officer needs.

Re-identification

Workers walk out of frame and come back. An appearance gallery keeps their id, so one person is one report instead of five.

VLM as a second opinion

The vision-language model writes a short, readable sentence from the crop. It runs only on confirmed cases, so it stays affordable even on a CPU.

Swappable detectors

SafetyVision (YOLOv8s, 13 classes) or CHD (YOLO26-L); the infraction list adapts to the chosen model.

Fast reruns

The app caches the processed video, so changing the infraction filter re-selects reports instantly.