A comprehensive deep learning project for object detection using the KITTI dataset, specifically designed for self-driving car applications. This project implements YOLOv8-based object detection with support for training, inference, and evaluation on KITTI data.
This project provides a complete pipeline for:
- Object Detection: Cars, vans, trucks, pedestrians, cyclists, trams, and misc objects
- KITTI Dataset Integration: Seamless handling of KITTI format data
- YOLOv8 Implementation: State-of-the-art object detection model
- Self-Driving Car Focus: Optimized for autonomous vehicle scenarios
- Comprehensive Evaluation: Detailed metrics and visualization
# Clone the repository (if needed)
git clone <your-repo-url>
cd kitti-object-detection
# Run setup script
python setup.py# Train with default settings (uses sample dataset)
python train.py --epochs 10
# Train with custom parameters
python train.py --model yolov8s --batch-size 32 --epochs 100# Inference on single image
python inference.py --source path/to/image.jpg --weights yolov8n.pt
# Inference on webcam
python inference.py --source 0 --weights yolov8n.pt --show
# Inference on directory
python inference.py --source path/to/images/ --weights runs/train/exp/weights/best.ptkitti-object-detection/
βββ src/ # Source code
β βββ data/
β β βββ kitti_dataset.py # KITTI dataset loader
β βββ models/
β β βββ detector.py # YOLOv8 detector wrapper
β βββ utils/
β βββ data_utils.py # Data processing utilities
βββ config/
β βββ config.yaml # Configuration file
βββ data/ # Dataset directory
β βββ kitti/ # Original KITTI data
β βββ sample_kitti/ # Sample dataset for testing
βββ weights/ # Model weights
βββ runs/ # Training/inference results
βββ train.py # Training script
βββ inference.py # Inference script
βββ evaluate.py # Evaluation script
βββ setup.py # Setup and installation
βββ requirements.txt # Python dependencies
- Multi-class Object Detection: 8 KITTI object classes
- Real-time Inference: Optimized for speed and accuracy
- Video Processing: Support for video files and webcam
- Batch Processing: Efficient directory processing
- Custom Visualization: Enhanced bounding box visualization
- Transfer Learning: Pre-trained YOLOv8 weights
- Data Augmentation: Advanced augmentation pipeline
- Mixed Precision: Memory-efficient training
- Early Stopping: Prevent overfitting
- Experiment Tracking: Organized result logging
- Comprehensive Metrics: mAP, precision, recall, F1-score
- Per-class Analysis: Detailed class-wise performance
- Visualization: Plots and charts for analysis
- KITTI Evaluation: Compatible with KITTI evaluation protocols
- Car - Standard passenger cars
- Van - Delivery vans and larger vehicles
- Truck - Heavy trucks and commercial vehicles
- Pedestrian - Walking people
- Person_sitting - Sitting people
- Cyclist - People on bicycles
- Tram - Public transport trams
- Misc - Other objects and vehicles
# 1. Visit KITTI website
# http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=2d
# 2. Download required files:
# - Left color images of object data set (12 GB)
# - Training labels of object data set (5 MB)
# 3. Extract to data/kitti/ directory
# 4. Convert to YOLO format
python -c "from src.utils.data_utils import setup_kitti_dataset; setup_kitti_dataset()"Edit config/config.yaml to customize:
# Model Configuration
model:
name: "yolov8n" # yolov8n, yolov8s, yolov8m, yolov8l, yolov8x
num_classes: 8
# Training Configuration
training:
epochs: 100
batch_size: 16
learning_rate: 0.01
# Dataset Configuration
dataset:
img_size: [640, 640]
classes: ["Car", "Van", "Truck", "Pedestrian", "Person_sitting", "Cyclist", "Tram", "Misc"]# Basic training
python train.py
# Custom dataset
python train.py --data path/to/dataset.yaml
# Resume training
python train.py --resume runs/train/exp/weights/last.pt
# Multi-GPU training
python train.py --device 0,1,2,3
# Validation during training
python train.py --validate# Image inference
python inference.py --source image.jpg --weights best.pt --conf 0.25
# Video inference
python inference.py --source video.mp4 --weights best.pt --save
# Webcam inference
python inference.py --source 0 --show
# Batch inference
python inference.py --source images_folder/ --save-json# Evaluate trained model
python evaluate.py --weights runs/train/exp/weights/best.pt --data dataset.yaml
# Custom evaluation settings
python evaluate.py --weights best.pt --data dataset.yaml --conf 0.001 --iou 0.6Expected performance on KITTI dataset:
| Model | mAP@0.5 | mAP@0.5:0.95 | Speed (ms) | Params (M) |
|---|---|---|---|---|
| YOLOv8n | 0.65+ | 0.45+ | ~10 | 3.2 |
| YOLOv8s | 0.70+ | 0.50+ | ~15 | 11.2 |
| YOLOv8m | 0.75+ | 0.55+ | ~25 | 25.9 |
| YOLOv8l | 0.78+ | 0.58+ | ~35 | 43.7 |
| YOLOv8x | 0.80+ | 0.60+ | ~50 | 68.2 |
Results may vary based on dataset size and training configuration
- Python 3.8+
- PyTorch 1.12+
- CUDA (optional, for GPU acceleration)
# Install dependencies
pip install -r requirements.txt
# Create directories
mkdir -p data weights logs results runs
# Download sample models
python -c "from ultralytics import YOLO; YOLO('yolov8n.pt')"FROM ultralytics/ultralytics:latest
WORKDIR /workspace
COPY . .
RUN pip install -r requirements.txt-
CUDA out of memory
# Reduce batch size python train.py --batch-size 8 -
Dataset not found
# Create sample dataset python -c "from src.utils.data_utils import create_sample_dataset; create_sample_dataset()"
-
Import errors
# Reinstall requirements pip install -r requirements.txt --force-reinstall
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests and documentation
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- KITTI Dataset creators and maintainers
- Ultralytics team for YOLOv8
- PyTorch community
- Self-driving car research community
For questions and support:
- Create an issue in this repository
- Check the documentation
- Review existing issues for solutions
Happy Autonomous Driving! ππ¨