Real-time PPE compliance monitoring that fuses object detection (PPE) with human pose estimation to flag unsafe conditions on the fly. Works on webcam or video files, overlays a clean HUD, and can log per-frame events for later analysis.
TL;DR → Plug camera/video in → YOLOv8 (PPE + Pose) → rule engine → annotated video & JSON/CSV events.
example1_cut_processed.mp4
example_workers.1.mp4
- 🔍 Dual-model fusion: YOLOv8 PPE detection + YOLOv8 Pose keypoints
- ⏱ Per-frame compliance checks: Hardhat, Mask, Safety Vest + posture cues
- 🎥 HUD overlays: Bounding boxes, skeletons, compliance banners
- 📹 Webcam & file support: Stream live or process pre-recorded videos
- 🖥 Pure PyTorch: No OpenVINO required
- 🗂 Sample assets: Ready-to-test images & videos
pose-vision/
├─ scripts/
│ ├─ video_pipeline.py
│ ├─ webcam_pipeline.py
│ └─ test/
│ ├─ fine_tuned_posture.py
│ ├─ improved_pose.py
│ ├─ yolo_pose_image.py
│ ├─ yolo_pose_video.py
│ ├─ yolo_pose_webcam.py
│ └─ yolo_webcam.py
├─ models/
│ ├─ ppe.yaml
│ ├─ yolov8n-pose.pt
│ └─ yolov8n-ppe.pt
├─ assets/
│ ├─ images/input.jpg
│ └─ videos/
│ ├─ example1.mp4
│ ├─ example2.mp4
│ ├─ example_workers.mp4
│ ├─ output_pose.mp4
│ └─ SCreenRec.mp4
└─ Presentation/
├─ AI-Powered-PPE-Compliance-Monitoring.pptx.pdf
└─ Pose-Aware-PPE-Compliance-System.pptx.pdf
- Pose model:
models/yolov8n-pose.pt - PPE detector:
models/yolov8n-ppe.pt - Class map (
ppe.yaml):
0: Hardhat
1: Mask
2: NO-Hardhat
3: NO-Mask
4: NO-Safety Vest
5: Person
6: Safety Cone
7: Safety Vest
8: machinery
9: vehicle
Python 3.9+ recommended.
# Clone repo
git clone https://github.com/Harshitheccentric/pose-vision.git
cd pose-vision
# Create virtual environment
python -m venv .venv
# Windows: .venv\Scripts\activate
# Linux/Mac:
source .venv/bin/activate
# Install dependencies
pip install --upgrade pip
pip install ultralytics opencv-python numpy torch torchvision pyyaml tqdm✅ No OpenVINO dependency needed.
python scripts/webcam_pipeline.py \
--ppe-weights models/yolov8n-ppe.pt \
--pose-weights models/yolov8n-pose.pt \
--source 0 \
--view \
--savepython scripts/video_pipeline.py \
--ppe-weights models/yolov8n-ppe.pt \
--pose-weights models/yolov8n-pose.pt \
--input assets/videos/example_workers.mp4 \
--out runs/annotated_example.mp4 \
--save-logs runs/example_events.json- PPE detection – YOLOv8 finds workers + gear
- Pose estimation – YOLOv8-Pose gives 17 keypoints
- Fusion – Match PPE boxes with persons (IoU overlap)
- Posture analysis – Angles & heuristics (from
fine_tuned_posture.py) - Rule engine – Flag violations (e.g., no helmet, bent spine)
- Output – Annotated video + optional JSON/CSV logs
flowchart LR
A[Video or Webcam Source] --> B[Frame Grab]
B --> C1[YOLOv8 PPE Detection]
B --> C2[YOLOv8 Pose Estimation]
C1 --> D[Fusion and Association person to PPE overlap]
C2 --> D
D --> E[Posture Module angles and heuristics]
E --> F[Compliance Rule Engine]
F --> G[HUD Overlay boxes skeletons banners]
F --> H[Event Logger JSON or CSV]
G --> I[Annotated Video Output]
H --> I
Located under scripts/test/:
yolo_webcam.py→ PPE-only webcamyolo_pose_webcam.py→ Pose-only webcamyolo_pose_video.py→ Pose on videoyolo_pose_image.py→ Pose on single imageimproved_pose.py→ Enhanced visualizationfine_tuned_posture.py→ Posture classification logic
Video: Annotated MP4 with skeletons & labels Logs (JSON/CSV):
{
"frame": 123,
"person_id": 5,
"violations": ["NO-Hardhat", "NO-Safety Vest"],
"posture": {"back_bend_deg": 32.1, "risk": "medium"},
"timestamp": "00:00:04.10"
}yolo detect train data=models/ppe.yaml model=yolov8n.pt imgsz=640 epochs=50 batch=16yolo pose train data=your_pose.yaml model=yolov8n-pose.pt imgsz=640 epochs=100- No webcam feed → Ensure
--source 0is correct and camera is free - CUDA not detected → Install correct PyTorch build for your GPU
- Slow FPS → Use
yolov8nfor speed; scale up tos/m/lonly if GPU allows