Skip to content

KrishPatel1205/Vehicle-Detection-and-Classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🚗 Vehicle Detection and Classification

This project is a real-time vehicle detection system built using Ultralytics YOLO. It identifies and classifies different types of vehicles in both live webcam feeds and pre-recorded videos.

The model was custom-trained on a dataset I created from scratch using real-world traffic footage. I manually labeled thousands of images to build a dataset tailored for detecting five specific vehicle categories: Ambulance, Bus, Car, Motorcycle, and Truck. This helped the model perform accurately in real-world urban scenarios.

🔍 Features

  • 📹 Real-time detection via webcam or video file
  • 🎯 Custom-trained YOLO model with 5 vehicle classes
  • 📦 Bounding boxes with labels drawn on detected vehicles
  • 💾 Outputs saved with annotated video frames
  • 🛠️ CLI interface for flexible usage

🚀 Classes Used

ID Class Name
0 Ambulance
1 Bus
2 Car
3 Motorcycle
4 Truck

🖥️ Demo

Example 1

video1.mp4

Example 2

video3.mp4

🧰 Installation

1. Clone the Repository

git clone https://github.com/yourusername/vehicle-detection.git
cd vehicle-detection

2. Download YOLO Detection Script

curl -o yolo_detect.py https://raw.githubusercontent.com/EdjeElectronics/Train-and-Deploy-YOLO-Models/refs/heads/main/yolo_detect.py

3. Install PyTorch

Visit pytorch.org to install the correct version for your system.

Example for M2 Pro MacBook:

pip3 install torch torchvision torchaudio

▶️ Running the Model

Using a Video File

python3 yolo_detect.py --model my_model.pt --source <path_to_video_file> --resolution 1920x1080

Using a Webcam

python3 yolo_detect.py --model my_model.pt --source usb0 --resolution 1920x1080

About

A computer vision project built with YOLO 11s to detect and classify vehicles in real-time using either a webcam or a video file as input. The model detects and classifies vehicles into five categories: Ambulance, Bus, Car, Motorcycle, and Truck.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages