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.
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.
- 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.
Comparing the original dashcam perspective with our semantic segmentation overlay. The model effectively highlights drivable lane boundaries.
The model produces probability distributions for lane boundaries. The heatmaps below demonstrate the model's confidence across different segments of the road.
The training progression shows steady convergence of both the BCE-Dice Loss and the Intersection over Union (IoU) metric across epochs.
Distribution of model confidence and error rates across the evaluation subset.
.
├── 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
You can directly run the training pipeline using a free GPU.
- Open Google Colab.
- Upload
src/train.py,src/visualize.py, andsrc/colab-quickstart.py. - Run the quickstart or the commands below:
# Install dependencies !pip install torch torchvision opencv-python numpy matplotlib seaborn scikit-learn albumentations tqdm
# 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.txtThe 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
To start training from scratch:
python src/train.pyNote: Adjust DATA_ROOT, BATCH_SIZE, and NUM_EPOCHS inside train.py depending on your hardware limits.
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| 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 |
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
- CULane dataset by Xingang Pan et al.
- U-Net architecture by Olaf Ronneberger et al.
- Developed for NYU Data Science course DSGA1007.
MIT License - Open for academic and research purposes.



