Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Semantic Segmentation for Autonomous Lane Detection

Lane Detection Results

A complete implementation of a lane detection system using a U-Net architecture trained on the CULane dataset. This project applies deep learning-based semantic segmentation to accurately identify lane boundaries in real-time.

Project Overview

This project focuses on the challenging task of detecting lane markings under diverse and complex driving scenarios (such as sunny highways, urban streets, night driving, and shadows). The underlying model is based on the U-Net architecture, achieving 70-75% IoU on the CULane dataset while running efficiently at 25-40 FPS.

Key Features

  • Architecture: Deep U-Net structure (~31M parameters).
  • Training Scale: Trained on 133,235 CULane images.
  • Performance: Real-time capable (30+ FPS) with low inference latency.
  • Robustness: Effective across different lighting conditions and scenarios.
  • Accessibility: Includes a Colab-ready quickstart for free T4 GPU training.

📸 Output & Results

Before and After Comparison

Comparing the original dashcam perspective with our semantic segmentation overlay. The model effectively highlights drivable lane boundaries.

Before/After Comparison

Confidence Heatmaps

The model produces probability distributions for lane boundaries. The heatmaps below demonstrate the model's confidence across different segments of the road.

Confidence Heatmaps

Training History (Loss and IoU)

The training progression shows steady convergence of both the BCE-Dice Loss and the Intersection over Union (IoU) metric across epochs.

Training History

Performance Metrics Distribution

Distribution of model confidence and error rates across the evaluation subset.

Metrics Distribution


📁 Project Structure

.
├── src/
│   ├── train.py                 # Main training pipeline and U-Net Model
│   ├── visualize.py             # Inference and visualization generation
│   └── colab-quickstart.py      # Quick execution script for Google Colab
├── notebooks/
│   └── Lane_Detection_ts5789_Project(GDrive).ipynb # Exploration and EDA
├── docs/
│   ├── PROJECT-SUMMARY.md       # Extended project description
│   ├── DSGA1007_presentation.pdf# Final presentation slides
│   └── LANE DETECTION PROJECT.pdf # Project final report
├── results/
│   ├── before_after_comparison.png
│   ├── confidence_heatmaps.png
│   ├── metrics_distribution.png
│   ├── training_history.png
│   └── best_model.pth           # Saved model weights (Not in Repo - >100MB)
├── requirements.txt             # Python dependencies
├── .gitignore                   # Ignore definitions
└── README.md                    # This file

🚀 Installation & Setup

Option 1: Google Colab (Recommended)

You can directly run the training pipeline using a free GPU.

  1. Open Google Colab.
  2. Upload src/train.py, src/visualize.py, and src/colab-quickstart.py.
  3. Run the quickstart or the commands below:
    # Install dependencies
    !pip install torch torchvision opencv-python numpy matplotlib seaborn scikit-learn albumentations tqdm

Option 2: Local Installation

# Clone the repository
git clone https://github.com/7dracoder/Semantic-Segmentation-for-Autonomous-Lane-Detection.git
cd Semantic-Segmentation-for-Autonomous-Lane-Detection

# Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install requirements
pip install -r requirements.txt

💾 Dataset Preparation

The project uses the CULane Dataset.

Download from Kaggle (Easiest Method):

pip install kaggle
# Ensure kaggle.json is in ~/.kaggle/
kaggle datasets download -d manideep1108/culane
unzip culane.zip -d data/

Dataset Structure:

data/
└── culane/
    ├── list/
    ├── driver_*_*frame/  # Raw images
    └── laneseg_label_w16/ # Labels

🧠 Usage & Training

Training the Model

To start training from scratch:

python src/train.py

Note: Adjust DATA_ROOT, BATCH_SIZE, and NUM_EPOCHS inside train.py depending on your hardware limits.

Visualizing Results

To run inference and generate plots similar to the ones above:

from src.visualize import create_comprehensive_report
from src.train import UNet
import torch

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = UNet().to(device)

# Ensure you have the checkpoint downloaded/saved locally
checkpoint = torch.load('results/best_model.pth')
model.load_state_dict(checkpoint['model_state_dict'])

# Run your dataloader here to evaluate

📊 Performance by Scenario

Scenario IoU Score Status
Sunny Highway 0.85 Excellent ✅
Urban Streets 0.75 Very Good ✅
Night Driving 0.72 Good ✅
Shadows 0.70 Good ✅
Curves 0.68 Acceptable ⚠️
Heavy Rain 0.50 Challenging ⚠️

🛠 Model Architecture (U-Net)

Input (3×256×512)
    ↓
Encoder (4 levels: 64 -> 128 -> 256 -> 512 filters)
    ↓
Bottleneck (1024 filters)
    ↓
Decoder (4 levels with Skip Connections)
    ↓
Output (1×256×512) - Probability Map
  • Total Parameters: ~31M
  • Model Size: 125 MB

Acknowledgments

  • CULane dataset by Xingang Pan et al.
  • U-Net architecture by Olaf Ronneberger et al.
  • Developed for NYU Data Science course DSGA1007.

License

MIT License - Open for academic and research purposes.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages