Highway Vehicle Detection - Complete Project

A comprehensive vehicle detection system for highway traffic monitoring, including trained models, datasets, videos, and complete source code.

📁 Project Contents

🤖 Trained Models

  • runs/detect/yolov8m_stage1_smart/weights/best.pt - Stage 1 model
  • runs/detect/yolov8m_stage2_improved/weights/best.pt - Final improved model

📊 Datasets

  • dataset/ - Main training dataset (8,219 images + labels)
  • new_finetunedata/ - Fine-tuning dataset (92 images + labels)

🎬 Videos

  • input and output/test_video.mp4 - Input test video
  • input and output/detection_output_improved.mp4 - Output with detections

💻 Source Code

  • main.py - Main application for vehicle detection and counting
  • test_improved_model.bat - Testing script
  • PROJECT_REPORT.md - Complete project documentation

📋 Configuration

  • dataset/data.yaml - Main dataset configuration
  • new_finetunedata/data.yaml - Fine-tuning dataset configuration
  • requirements.txt - Python dependencies

🚀 Quick Start

Installation

pip install ultralytics opencv-python numpy

Run Detection

from ultralytics import YOLO

# Load the trained model
model = YOLO('runs/detect/yolov8m_stage2_improved/weights/best.pt')

# Process video
results = model('input and output/test_video.mp4', save=True)

Using the Main Application

python main.py

📈 Model Performance

Classes Detected

  1. auto - Three-wheelers
  2. bus - Public transport vehicles
  3. car - Passenger cars
  4. lcv - Light Commercial Vehicles
  5. motorcycle - Two-wheelers
  6. multiaxle - Multi-axle heavy vehicles
  7. tractor - Agricultural/construction vehicles
  8. truck - Heavy vehicles

Training Stages

  • Stage 1: Initial training on 8,219 highway images
  • Stage 2: Fine-tuning on 92 additional images for improved truck/bus detection

📊 Dataset Statistics

Main Dataset (dataset/)

  • Images: 8,219 highway traffic images
  • Labels: 8,219 corresponding annotation files
  • Classes: 8 vehicle types
  • Format: YOLO format (.txt files)

Fine-tuning Dataset (new_finetunedata/)

  • Images: 92 additional images
  • Focus: Improved truck and bus detection
  • Classes: Enhanced examples for problematic classes

🎯 Applications

  • Highway traffic monitoring
  • Vehicle counting and classification
  • Traffic flow analysis
  • Automated surveillance systems
  • Road safety monitoring
  • Traffic data collection

📁 File Structure

highway-vehicle-detection-full/
├── runs/
│   └── detect/
│       ├── yolov8m_stage1_smart/
│       │   └── weights/
│       │       ├── best.pt
│       │       └── last.pt
│       └── yolov8m_stage2_improved/
│           └── weights/
│               ├── best.pt
│               └── last.pt
├── dataset/
│   ├── data.yaml
│   └── train/
│       ├── images/ (8,219 images)
│       └── labels/ (8,219 label files)
├── new_finetunedata/
│   ├── data.yaml
│   └── train/
│       ├── images/ (92 images)
│       └── labels/ (92 label files)
├── input and output/
│   ├── test_video.mp4
│   └── detection_output_improved.mp4
├── main.py
├── PROJECT_REPORT.md
├── requirements.txt
└── README.md

🔧 Technical Details

  • Model Architecture: YOLOv8m (Medium)
  • Framework: Ultralytics YOLO
  • Input Format: Images/Videos
  • Output Format: Bounding boxes with class labels and confidence scores
  • Training Hardware: GPU recommended
  • Inference: CPU/GPU compatible

📝 Usage Examples

Basic Detection

from ultralytics import YOLO
import cv2

# Load model
model = YOLO('runs/detect/yolov8m_stage2_improved/weights/best.pt')

# Detect objects in image
results = model('path/to/image.jpg')

# Process results
for result in results:
    boxes = result.boxes
    for box in boxes:
        x1, y1, x2, y2 = box.xyxy[0]
        conf = box.conf[0]
        cls = int(box.cls[0])
        print(f"Class: {cls}, Confidence: {conf:.2f}")

Video Processing

# Process video file
results = model('input and output/test_video.mp4', save=True, save_txt=True)

📄 License

MIT License - See LICENSE file for details

🤝 Contributing

This is a research project. For questions or improvements, please contact the author.

📞 Contact

Author: Nguyen Quoc Viet
Repository: https://huggingface.co/datasets/bichuche0705/highway-vehicle-detection-full

📚 Citation

If you use this dataset or model in your research, please cite:

@misc{highway-vehicle-detection-full,
  title={Highway Vehicle Detection - Complete Project},
  author={Nguyen Quoc Viet},
  year={2024},
  url={https://huggingface.co/datasets/bichuche0705/highway-vehicle-detection-full}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support