This repository contains the implementation of a road segmentation project using two state-of-the-art deep learning models: YOLOv8-Seg and SegFormer. The objective of this project is to accurately identify and segment road surfaces in urban driving scenes using the CamVid dataset.
Object Detection and Road Segmentation Combined Video
The CamVid dataset, consisting of 701 images captured in various road scenarios, was used for training, validation, and testing. Each image is paired with a pixel-wise labeled mask, and the dataset is divided as follows:
- Training set: 367 images
- Validation set: 101 images
- Test set: 233 images
Dataset Link: CamVid Dataset - Kaggle
-
YOLOv8-Seg:
- Utilizes a bounding box-based approach for segmentation.
- Lightweight and suitable for real-time applications.
- Achieved high accuracy with lower computational cost.
-
SegFormer:
- Transformer-based architecture designed for semantic segmentation.
- Capable of capturing fine-grained details and sharper boundaries.
- Requires higher computational power but produces more precise segmentation maps.
The following evaluation metrics were used to assess model performance:
- Accuracy: Measures overall pixel-wise classification accuracy.
- F1-Score: Evaluates the balance between precision and recall.
- Precision: Indicates the proportion of correctly classified road pixels.
- Recall: Measures how well the model identifies road pixels among actual road pixels.
- IoU (Intersection over Union): Provides a comprehensive measure of overlap between predicted and ground truth masks.
Model | Accuracy | F1-Score | Precision | Recall | IoU |
---|---|---|---|---|---|
YOLOv8-Seg | 99% | 98% | 96% | 98% | 94% |
SegFormer | 97% | 95% | 95% | 94% | 92% |
- Clone the repository:
git clone https://github.com/karginb/Road_Segmentation.git
cd Road_Segmentation
- Download the CamVid dataset and place it in the
images/
directory.
https://www.kaggle.com/datasets/carlolepelaars/camvid
- Train the models:
python yolo_segment_train.py
python segformer_train.py
- Inference:
python yolo_segment_inference.py
python segformer_inference.py
- YOLOv8-Seg achieved faster inference times and demonstrated strong accuracy with minimal computational resources.
- SegFormer provided more detailed and refined segmentation maps, particularly in complex road patterns and occluded areas.
- The trade-off between processing speed and segmentation quality was evident, suggesting potential for hybrid models in future work.