FCTX's picture
Upload 7 files
c54cd04 verified
|
Raw
History Blame Contribute Delete
5.46 kB

A newer version of the Gradio SDK is available: 6.22.0

Upgrade
metadata
title: AI-PPE-Detection-System
sdk: gradio
app_file: app.py

AI-PPE-Detection-System

AI-powered PPE detection system for industrial safety monitoring.

Overview

This project detects workers and personal protective equipment such as helmets and safety vests from workplace images.
It is designed as a prototype for factory, warehouse, and construction site safety monitoring.

Unlike a simple YOLO object detection demo, this system associates PPE detections with each detected worker and produces an operational safety dashboard. The output is designed to be useful for supervisors, operations teams, AI portfolio reviewers, and prototype discussions with industrial clients.

Features

  • Worker detection
  • Helmet detection
  • Safety vest detection
  • PPE compliance check
  • Worker count
  • Helmet compliance summary
  • Vest compliance summary
  • Per-worker PPE assessment table
  • Missing PPE item summary
  • Detection details table with assigned / unassigned PPE status
  • Adjustable confidence threshold
  • Adjustable IoU threshold
  • Annotated detection image
  • Gradio web UI
  • Hugging Face Spaces compatible

Industrial AI Use Cases

This system can be used as a prototype for industrial safety monitoring applications.

  • Factory PPE Monitoring
  • Safety Compliance Check
  • Worker Safety Analytics
  • Smart Factory AI
  • Construction Site Safety Monitoring
  • Warehouse Safety Monitoring

Demo Behavior

Upload a factory, warehouse, construction site, or worker image. The app returns:

  • An annotated image with detected workers and PPE
  • Site Safety Status
  • PPE Check Result table
  • Worker Safety Summary table
  • Per-worker PPE assessment table
  • Detection details table

PPE judgment rules:

  • Helmet is OK when helmet or hardhat evidence is detected and associated with a worker.
  • Safety Vest is OK when safety vest evidence is detected and associated with a worker.
  • Overall Result is OK only when all detected workers are compliant.
  • If any detected worker is missing a helmet or safety vest, the site safety status is NG.

Worker safety summary rules:

  • Workers is the number of detected person objects.
  • Helmet Compliance is the number of workers with a helmet inside their person box divided by total workers.
  • Vest Compliance is the number of workers with a safety vest inside their person box divided by total workers.
  • Fully Compliant Workers is the number of workers with both required PPE items divided by total workers.
  • If no workers are detected, the summary shows No workers detected.

System Logic

The application runs two object detection passes:

  1. A COCO YOLO model detects workers using the person class.
  2. A PPE YOLO model detects helmet, hardhat, safety vest, and missing-PPE labels.

PPE boxes are assigned to the most likely worker using box overlap and center-point checks. This makes the result more useful than a raw object list because the app can answer operational questions such as:

  • Which worker is missing required PPE?
  • How many workers are fully compliant?
  • What is the current helmet compliance ratio?
  • What is the current safety vest compliance ratio?
  • Which PPE detections could not be assigned to a worker?

Tech Stack

  • Python
  • Gradio
  • YOLO
  • OpenCV
  • Pillow
  • NumPy
  • Hugging Face Hub
  • Hugging Face Spaces

Models

Person detection:

  • Model: yolov8n.pt
  • Source: Ultralytics COCO pretrained model
  • Class used: person

PPE detection:

The PPE model is downloaded at runtime with huggingface_hub. The COCO person model is loaded by Ultralytics at runtime, so large model files do not need to be committed to this repository.

How to Run

pip install -r requirements.txt
python app.py

Open the local Gradio URL shown in the terminal, upload an image, and click Run Site Safety Check.

Hugging Face Spaces

This repository is ready for Hugging Face Spaces.

  1. Create a new Space.
  2. Select Gradio as the SDK.
  3. Upload this repository.
  4. The Space will run app.py automatically.

Accuracy Notes

Detection quality depends on image quality, lighting, occlusion, worker distance, camera angle, and the model training data. For better results:

  • Use clear images where workers, helmets, and vests are visible.
  • Avoid images where workers are extremely small.
  • Lower confidence thresholds if valid detections are missed.
  • Raise confidence thresholds if false detections are frequent.
  • Treat this project as a prototype, not as the only safety-control mechanism in a real workplace.

File Structure

AI-PPE-Detection-System/
+-- app.py
+-- requirements.txt
+-- README.md
+-- .gitignore
+-- sample_images/
    +-- README.md

Portfolio Point

This project demonstrates practical AI implementation for industrial safety monitoring, combining object detection, rule-based safety judgment, and user-friendly visualization.

It shows how YOLO-based detection can be turned into a workplace-oriented AI safety monitoring prototype for factories, warehouses, and construction sites.

Contact

Consultation Form: https://forms.gle/SaWGZFu8J7DgbytL7

Follow My Work