Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Helmet Detection System

A real-time helmet detection web app powered by a custom-trained YOLOv8 model. Upload an image or video and the system draws bounding boxes around detected helmets, persons, and motorcycles — instantly telling you whether a helmet is present or not.

Python FastAPI React TypeScript YOLOv8


Demo

Helmet Detected ✅ No Helmet ❌
Green bounding box drawn around helmet Red alert — no helmet found in frame

✨ Features

  • 🖼️ Image detection — upload JPG, PNG, or WEBP and get an annotated result instantly
  • 🎥 Video detection — upload MP4/MOV and every frame is processed; annotated video returned
  • 🟢 Clear verdict — "Helmet detected" or "No helmet detected" shown prominently
  • 📦 Bounding boxes — color-coded per class (helmet, person, motorcycle)
  • 📊 Detection table — confidence scores and box coordinates for every detection
  • ⬇️ Download result — save the annotated image or video directly from the UI

🧠 Model

  • Architecture: YOLOv8n (nano — fast inference)
  • Dataset: Open Images V7 (via FiftyOne)
  • Classes: helmet · person · motorcycle
  • Training: 35 epochs · 640px · batch 32 · Google Colab GPU
  • Weights file: best.pt (not included in repo — see setup below)

🗂️ Project Structure

helmet-detection/
├── backend/
│   ├── main.py              # FastAPI app — detection endpoints
│   ├── requirements.txt     # Python dependencies
│   └── weights/
│       └── best.pt          # ← place your model weights here
└── frontend/
    ├── src/
    │   ├── App.tsx
    │   ├── components/      # DropZone, ResultPanel, DetectionTable …
    │   ├── hooks/           # useDetection
    │   └── utils/           # API calls, TypeScript types
    ├── package.json
    └── vite.config.ts

🚀 Getting Started

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Your trained best.pt weights file

🔌 API Endpoints

Method Endpoint Description
GET /health Health check + loaded classes
POST /detect/image Upload image → annotated image + detections
POST /detect/video Upload video → annotated video + frame stats

🛠️ Tech Stack

Layer Technology
Model YOLOv8n (Ultralytics)
Backend FastAPI + Uvicorn
Image processing OpenCV
Frontend React 18 + TypeScript
Bundler Vite
Icons Lucide React

📓 Training Notebook

The model was trained in Google Colab using:

  • FiftyOne to download and prepare Open Images V7
  • YOLOv8n fine-tuned for 35 epochs on helmet/person/motorcycle classes
  • Export to YOLO format → trained with ultralytics trainer

See notebook/final.ipynb for the full training pipeline.


🤝 Contributing

Pull requests are welcome. For major changes, open an issue first to discuss what you'd like to change.


📄 License

MIT License — feel free to use, modify, and distribute.

About

A YOLOv8n Model trained to detect helmet, person, motorcycle classes. With full FastAPI + TypeScript frontend project.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages