This project focuses on water/flood segmentation from multispectral satellite imagery using deep learning.
Satellite images contain 12 spectral bands, which provide more environmental information compared to traditional RGB images.
The objective of this project is to build a model capable of detecting and segmenting water bodies using semantic segmentation techniques.
Two deep learning approaches were implemented:
1️ Custom U-Net (Keras / TensorFlow)
2️ Transfer Learning U-Net (PyTorch + ResNet34 Encoder)
The models were trained and evaluated to compare their performance on water segmentation tasks.
Each sample in the dataset contains:
- Format:
.tif - Size:
128 × 128 - Channels: 12 spectral bands
- Format:
.png - Binary mask
1 = Water
0 = Background
Each satellite image contains the following 12 channels:
- Coastal Aerosol
- Blue
- Green
- Red
- NIR
- SWIR1
- SWIR2
- QA Band
- Merit DEM
- Copernicus DEM
- ESA World Cover Map
- Water Occurrence Probability
These bands provide valuable environmental and spectral information useful for water detection.
The preprocessing pipeline included:
- Convert images to float32
- Band-wise normalization
- Convert masks to binary format
- Preserve original spatial resolution
128×128
Dataset split:
Train: 80%
Validation: 10%
Test: 10%
To improve model generalization, several augmentation techniques were applied:
- Horizontal Flip
- Vertical Flip
- Random Rotation
- Shift / Scale / Rotate
- Random Brightness & Contrast
These augmentations increase dataset diversity and reduce overfitting.
Two segmentation models were implemented and trained.
A fully customized U-Net architecture was implemented using Keras.
Input Shape: 128 × 128 × 12
Architecture: Encoder–Decoder (U-Net)
Output: Binary segmentation mask
Loss Function:
Binary Crossentropy
Optimizer:
Adam
Metric:
Jaccard Coefficient (IoU)
The model achieved strong performance during training:
Validation Accuracy ≈ 0.978
Validation IoU ≈ 0.90
Training stopped using Early Stopping to prevent overfitting.
Example training log:
Epoch 158 → Best Validation IoU ≈ 0.9017
This model achieved the best performance in this project.
A U-Net with ResNet34 encoder was implemented using PyTorch.
Since most pretrained models expect 3-channel RGB images, the first convolution layer was modified to accept:
Input Channels = 12
All layers remained trainable to adapt to multispectral satellite data.
Encoder: ResNet34
Input Channels: 12
Output Classes: 1
Activation: None (logits output)
Loss Function:
BCEWithLogitsLoss + Dice Loss
Optimizer:
Adam
Learning Rate:
5e-5
Train IoU ≈ 0.77
Validation IoU ≈ 0.83
The models were evaluated on the test dataset.
Test IoU: 0.8129
Precision: 0.9389
Recall: 0.8582
F1 Score: 0.8967
These results indicate strong performance for water segmentation in multispectral satellite imagery.
The following metrics were used to evaluate segmentation performance:
Measures overlap between predicted mask and ground truth.
Percentage of predicted water pixels that are correct.
Percentage of real water pixels detected by the model.
Balanced measure between precision and recall.
Model predictions were visualized using:
- Satellite Image (RGB band combination)
- Ground Truth Mask
- Predicted Segmentation Mask
This allows visual inspection of segmentation performance.
The project was implemented using:
- Python
- PyTorch
- TensorFlow / Keras
- segmentation-models-pytorch
- Rasterio
- OpenCV
- Albumentations
- NumPy
- Matplotlib
- Scikit-learn
project/
│
├── data/
│ ├── images
│ └── labels
│
├── notebooks/
│ └── training_notebook.ipynb
│
├── models/
│ └── best_model.pth
│ └── best_keras_model.h5
│
└── README.md
Possible improvements include:
- Using larger satellite datasets
- Trying advanced segmentation architectures
- Applying Test-Time Augmentation (TTA)
- Training with multispectral pretrained models
Armia Gamal
Computer Science & Statistics Student
AI Engineer | Computer Vision | Deep Learning