Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConvNeXt-UPerNet Crack Segmentation

Pixel-level pavement crack segmentation from UAV remote sensing images using ConvNeXt-UPerNet architecture. Implements the methodology from "Pixel-level pavement crack segmentation using UAV remote sensing images based on the ConvNeXt-UPerNet" (Taha et al., 2025).

Python PyTorch License

Architecture

Component Details
Encoder ConvNeXt (Tiny/Small/Base) with ImageNet pretrained weights
Decoder UPerNet with FPN + Pyramid Pooling Module
Input 400x400x3 RGB images
Output 400x400x1 binary segmentation masks
Loss Combined Dice + Focal Loss (handles severe class imbalance)

Sample Results

Project Structure

crack_segmentation_project/
├── model.py                  # ConvNeXt-UPerNet architecture
├── dataset.py                # Dataset loading (supports .mat masks)
├── losses.py                 # Loss functions (Dice, Focal, Tversky, Combined, Boundary)
├── train_convnext.py         # Training pipeline with mixed precision
├── evaluate_convnext.py      # Evaluation with comprehensive metrics
├── predict_convnext.py       # Inference with TTA support
├── models/
│   └── convnext.py           # Standalone ConvNeXt implementation
├── utils/
│   ├── augmentation.py       # Albumentations-based augmentation
│   └── patching.py           # Image patching and preprocessing
├── data/
│   ├── images/               # Input UAV images (118 samples)
│   └── masks/                # Ground truth masks (.mat format)
├── evaluation_results/       # Evaluation metrics and plots
├── results/                  # Prediction visualizations
├── plots/                    # Training curves
└── logs/                     # Training logs

Quick Start

Installation

git clone https://github.com/aliyanz85/cracks-detection-.git
cd cracks-detection-
pip install -r requirements.txt

Training

python train_convnext.py \
    --data_path data \
    --backbone convnext_tiny \
    --epochs 200 \
    --batch_size 8 \
    --learning_rate 1e-4

Evaluation

python evaluate_convnext.py \
    --model checkpoints/best.pth \
    --data data \
    --backbone convnext_tiny

Inference

# Single image
python predict_convnext.py \
    --model checkpoints/best.pth \
    --input path/to/image.jpg \
    --output predictions/

# Directory of images
python predict_convnext.py \
    --model checkpoints/best.pth \
    --input path/to/images/ \
    --output predictions/ \
    --tta  # Enable test-time augmentation

Key Features

  • Mixed Precision Training — Automatic FP16 for faster training on GPU
  • Advanced Augmentation — Geometric + photometric transforms via Albumentations
  • Test-Time Augmentation — Multi-flip ensemble for improved inference
  • Multiple Loss Functions — Dice, Focal, Tversky, Combined, Boundary-aware
  • Comprehensive Evaluation — IoU, Dice, F1, Precision, Recall, Confusion Matrix
  • Flexible Backbone — ConvNeXt Tiny/Small/Base variants

Training Configuration

Parameter Value
Optimizer AdamW (β₁=0.9, β₂=0.999)
Learning Rate 1e-4 with cosine annealing
Weight Decay 1e-4
Batch Size 8
Image Size 400x400
Epochs 200
Augmentation Flip, Rotate, Brightness, Contrast, Noise, Blur

Dataset

The project uses the DronePavSeg UAV pavement crack dataset:

  • 118 high-resolution UAV images
  • Ground truth segmentation masks in MATLAB .mat format
  • Binary labels: background (1) → 0, crack (2) → 1

Results

Evaluation on the test set:

Metric Score
Pixel Accuracy 96.7%
Precision 26.7%
Recall 58.9%
F1-Score 36.7%

Note: The low IoU/F1 reflects the extreme class imbalance in crack segmentation (cracks occupy <3% of pixels). Pixel accuracy is high due to the dominant background class. Further training with more epochs and hyperparameter tuning is recommended.

Requirements

  • Python 3.9+
  • PyTorch 1.12+
  • CUDA-capable GPU (recommended, 8GB+ VRAM)
  • See requirements.txt for full dependencies

References

  • Taha, M. et al. (2025). Pixel-level pavement crack segmentation using UAV remote sensing images based on the ConvNeXt-UPerNet.
  • Liu, Z. et al. (2022). A ConvNet for the 2020s. CVPR.
  • Xiao, T. et al. (2018). Unified Perceptual Parsing for Scene Understanding. ECCV.

License

MIT License

About

pixel wise crack detection and segmentation of roads pavements

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages