Advanced Deep Learning for Pixel-Level Analysis
EU-Philippines CoPhil Programme
Duration: 1.5 hours Type: Theory + Discussion Goal: Master semantic segmentation and U-Net for Earth Observation
You will learn:
Prerequisites:
Resources:
Semantic segmentation = classifying every pixel in an image into a category
Why it matters for EO
Pixel-level precision enables:
| Aspect | Classification | Object Detection | Semantic Segmentation |
|---|---|---|---|
| Question | What’s in this image? | Where are objects? | Which pixels are what? |
| Output | Single label | Bounding boxes + labels | Pixel-wise mask |
| Granularity | Image-level | Object-level | Pixel-level |
| Spatial Info | None | Approximate (boxes) | Precise (pixels) |
| Computation | Fast | Moderate | Intensive |
| Use Case | “Contains buildings” | “10 buildings detected” | “Building footprints mapped” |
Input: 256×256 satellite patch Output: “Urban area”
Info: General category only Precision: Image-level
Input: Satellite scene Output: 15 bounding boxes
Info: Approximate locations Precision: Object-level
Input: Satellite image Output: Pixel map (water/building/vegetation/road)
Info: Exact boundaries Precision: Pixel-level
Important
For EO applications requiring precise spatial analysis, segmentation is essential!
Precise Delineation
Quantitative Analysis
Change Detection
Decision Support
Developed by: Ronneberger et al. (2015) for biomedical image segmentation
Now: One of the most popular architectures for Earth Observation
Proven Track Record
U-Net achieves high accuracy in EO applications with just hundreds to thousands of training samples (vs millions for other deep learning approaches)
Purpose: Extract features
Purpose: Global context
Purpose: Reconstruct
Purpose: Extract hierarchical features at multiple scales while compressing spatial information
Input: 256×256×3 # RGB satellite image
↓ Conv Block 1
Block 1: 256×256×64 # After convolutions
↓ MaxPool (2×2)
Pool 1: 128×128×64 # Spatial dims halved
↓ Conv Block 2
Block 2: 128×128×128 # More channels
↓ MaxPool (2×2)
Pool 2: 64×64×128
↓ Conv Block 3
Block 3: 64×64×256
↓ MaxPool (2×2)
Pool 3: 32×32×256
↓ Conv Block 4
Block 4: 32×32×512
↓ MaxPool (2×2)
Pool 4: 16×16×512 # Ready for bottleneckCapture fine details:
Capture semantics:
Connection to Day 2
This is the same CNN hierarchy you learned! Early layers = low-level features, deep layers = high-level semantic features.
The central part of U-Net (bottom of the “U”)
What it captures:
Note
This trade-off is intentional! The decoder will reconstruct precise locations using skip connections.
Purpose: Reconstruct spatial resolution to create precise pixel-wise predictions
Bottleneck: 16×16×1024 # Most compressed
↓ Upsample (TransposeConv 2×2)
Upsample 1: 32×32×512 # Spatial doubled
↓ Concatenate with encoder Block 4 (32×32×512)
Concat: 32×32×1024 # 512 + 512 channels
↓ Conv Block
Conv Block: 32×32×512 # Refined features
↓ Upsample (TransposeConv 2×2)
Upsample 2: 64×64×256
↓ Concatenate with encoder Block 3 (64×64×256)
Concat: 64×64×512 # 256 + 256 channels
↓ Conv Block
Conv Block: 64×64×256
...
↓ Final Conv 1×1
Final: 256×256×num_classes # Full resolution!Why Skip Connections Matter
The Problem: Without skip connections, spatial information is lost during downsampling (pooling). The decoder would have to reconstruct precise boundaries from coarse bottleneck features only → blurry boundaries.
The Solution: Skip connections preserve edges and small structures by copying high-resolution encoder features directly to the decoder.
Result: Best of both worlds:
Without Skip Connections
With Skip Connections
. . .
Tip
This precision is critical for applications requiring legal boundaries, property lines, or hazard zone delineation!
Disaster response and damage assessment
Data Sources:
Task:
Typhoon Ulysses (2020)
Session 2 Preview
Tomorrow’s hands-on lab: Train U-Net for Central Luzon flood mapping using Sentinel-1 SAR data!
Environmental monitoring, urban planning, biodiversity assessment
Data Sources:
Task:
. . .
Task:
Applications:
Urban mapping, population estimation, disaster risk assessment
Philippine Context:
Precision agriculture, forestry, ecosystem health
Data Sources:
Task:
Proven Performance
Across all these applications, research shows:
Loss function = mathematical measure comparing predicted mask to ground truth
Unlike classification (one value), segmentation compares entire images pixel-by-pixel:
Focus: Individual pixel correctness
Example: Cross-Entropy
Asks: Is each pixel correct?
Focus: Spatial agreement
Example: Dice, IoU
Asks: Does predicted region match true region?
Focus: Edge precision
Example: IoU, Boundary Loss
Asks: Are edges precisely delineated?
Key Point
The choice of loss function critically affects model behavior. Poor choice → useless predictions!
Flood Mapping
Ship Detection
Building Segmentation
Why? Vanilla cross-entropy is dominated by majority class.
Result: Model predicts majority class for all pixels → high accuracy but no useful information!
For imbalanced EO data, loss functions must:
\[\text{Cross-Entropy} = -\sum_{i=1}^{N} y_{\text{true},i} \cdot \log(y_{\text{pred},i})\]
Where \(N\) = total number of pixels
When to use: Balanced datasets (~50/50 distribution) or with class weighting
Assign higher weight to under-represented classes
\[\text{Weighted CE} = -\sum_{i=1}^{N} w_{\text{class}} \cdot y_{\text{true},i} \cdot \log(y_{\text{pred},i})\]
Note
Weighted CE provides strong gradients while addressing imbalance, but still focuses on pixel-wise accuracy (not region overlap).
Measure overlap between prediction and ground truth regions
\[\text{Dice Coefficient} = \frac{2 \times |P \cap T|}{|P| + |T|}\]
\[\text{Dice Loss} = 1 - \text{Dice Coefficient}\]
Where:
Predicted: ████░░░░
True: ░░██████
Intersection: ██
Dice = 2×2/(4+6) = 0.40
Loss = 1 - 0.40 = 0.60
Better:
Predicted: ░░██████
True: ░░██████
Intersection: ██████
Dice = 2×6/(6+6) = 1.00
Loss = 0.00 ✓
Medical Imaging Parallel
Used to segment tumors (tiny area) in medical images—same challenge as small flood patches in vast satellite scenes!
Similar to Dice, directly optimizes the IoU metric
\[\text{IoU} = \frac{|P \cap T|}{|P \cup T|}\]
\[\text{IoU Loss} = 1 - \text{IoU}\]
Where \(\cup\) = union of predicted and true pixels
\[\text{Dice} = \frac{2 \times \text{IoU}}{1 + \text{IoU}}\]
Formula: \(\frac{2 \times \text{Intersection}}{\text{Sum of areas}}\)
Formula: \(\frac{\text{Intersection}}{\text{Union}}\)
Practical Guidance
In practice, both Dice and IoU work well for imbalanced EO data. Try both on your dataset—difference is often small. Dice is slightly more popular in training (smoother), IoU common for evaluation.
Combine complementary loss functions:
\[\text{Total Loss} = \alpha \cdot \text{CE Loss} + \beta \cdot \text{Dice Loss}\]
Where \(\alpha\) and \(\beta\) are weights (e.g., \(\alpha=0.5\), \(\beta=0.5\))
def combined_loss(y_true, y_pred):
# Cross-entropy component
ce = tf.keras.losses.categorical_crossentropy(
y_true, y_pred
)
# Dice loss component
dice = dice_loss(y_true, y_pred)
# Combine with equal weights
return 0.5 * ce + 0.5 * dice
# Use in model
model.compile(
optimizer='adam',
loss=combined_loss,
metrics=['accuracy', dice_coefficient, 'IoU']
)Additional Options
Focal Loss
Boundary Loss
Tversky Loss
| Application | Recommended Loss | Reason |
|---|---|---|
| Flood mapping | Dice or Combined | Severe imbalance, critical boundaries |
| Balanced land cover | Cross-Entropy | Classes relatively balanced |
| Building extraction | Dice or IoU | Precise footprints matter |
| Road extraction | Combined Loss | Thin features, need continuity |
| Ship detection | Dice | Extreme imbalance, small objects |
| Crop classification | Weighted CE or Combined | Moderate imbalance |
Scenario:
| Loss Function | IoU Score | Notes |
|---|---|---|
| Cross-Entropy | 0.12 | Predicts mostly non-flooded; trivial solution ✗ |
| Weighted CE | 0.54 | Better; weight=11.5×; some false positives |
| Dice Loss | 0.68 | Good recall; slightly noisy; handles imbalance ✓ |
| Combined (CE + Dice) | 0.73 | Best balance; stable training ✓✓ |
Loss Choice is Critical!
For flood mapping (binary segmentation, severe imbalance):
Difference: Trivial predictions vs. operationally useful model
The right loss pushes the model to correctly segment the minority class rather than achieving high but meaningless accuracy.
Semantic Segmentation
✓ Pixel-wise classification providing precise boundaries ✓ Differs from classification (labels) and detection (boxes) ✓ Essential for EO: exact spatial extent, area calculations ✓ Enables detailed thematic mapping and spatial analysis ✓ Critical for disaster response, planning, monitoring
U-Net Architecture
✓ Encoder-decoder structure with U-shape ✓ Skip connections = key innovation (preserve spatial details) ✓ Combines “what” (semantic context) + “where” (localization) ✓ Works with limited data (hundreds to thousands of samples) ✓ Widely adopted across EO community ✓ Uses same CNN building blocks from Day 2 ✓ Proven high accuracy in RS applications
Loss Functions
✓ Cross-Entropy: Standard, strong gradients, but imbalance-sensitive ✓ Weighted CE: Addresses imbalance via class weighting ✓ Dice/IoU: Inherently handle imbalance, optimize region overlap ✓ Combined losses often best in EO (e.g., CE + Dice) ✓ Choice critically impacts model behavior ✓ Consider: data balance, boundary importance, object size ✓ Can mean difference between useless and excellent results
EO Applications
✓ Flood mapping, land cover, buildings, roads, vegetation ✓ High accuracy even with small datasets ✓ Outperforms older pixel-based and patch-based methods ✓ Wide adoption across EO community ✓ Proven results in Philippine contexts (Typhoon Ulysses, urban mapping) ✓ From disaster response to urban planning to agriculture
Think About Your Problem!
Don’t just accept the default loss function.
Think about:
Then pick (or tune) your loss accordingly for the best results!
Session 2 Preview
What You’ll Do:
Dataset:
Foundational Paper:
Practice Datasets:
Before Session 2, consider:
What EO applications in your work could benefit from semantic segmentation vs classification/detection?
How would you validate segmentation results in the field for disaster response?
What challenges do you anticipate with limited training data for Philippine contexts?
How might transfer learning from other regions help Philippine EO applications?
Contact: Stylianos Kotsopoulos EU-Philippines CoPhil Programme
Next Session: Session 2: Flood Mapping Lab (Hands-on with U-Net)
Resources:
This session is part of the CoPhil 4-Day Advanced Training on AI/ML for Earth Observation, funded by the European Union under the Global Gateway initiative and delivered in partnership with PhilSA and DOST.

DAY 3 - Session 1 | U-Net for EO | 20-23 October 2025