This repository implements the Confident Naturalness Explanation (CNE) framework, a novel approach for assessing and explaining patterns that form naturalness in protected areas through the analysis of satellite imagery. The framework combines explainable AI and uncertainty quantification to provide a quantitative metric that describes the confident contribution of specific land cover patterns to the concept of naturalness.
Protected natural areas characterized by minimal modern human footprint are often challenging to assess. The CNE framework addresses this by:
- Extracting land cover patterns from satellite imagery using semantic segmentation
- Quantifying the importance of each pattern through surrogate modeling
- Estimating uncertainty using Monte Carlo dropout
- Combining importance and certainty into a single CNE metric
- Gray-Box Approach: Combines a black-box semantic segmentation model with a transparent white-box surrogate model
- Uncertainty Quantification: Uses Monte Carlo dropout to estimate epistemic uncertainty
- CNE Metric: Provides a quantifiable value (0-1) for each pattern's confident contribution to naturalness
- Uncertainty-Aware Segmentation: Generates maps showing uncertainty levels at pixel level
The explainability part consists of:
- Black-Box Model: DeepLabV3 semantic segmentation model trained on CORINE land cover classes
- Vectorization: Converting segmentation masks to pattern distribution vectors
- White-Box Model: Logistic regression to identify feature importance for naturalness classification
- Monte Carlo Dropout: Enabling dropout at inference time to sample from multiple model versions
- Standard Deviation: Calculating variability across Monte Carlo samples to measure uncertainty
- Spatial Aggregation: Summing uncertainty values across spatial dimensions
The CNE metric combines importance coefficients (α) from the explainability component with uncertainty values (u) from the uncertainty quantification:
CNE_c = α_c+ / u_c
Where:
α_c+= max(α_c, 0) - only positive coefficients are considered (patterns that positively contribute to naturalness)u_c= sum of standard deviation across spatial dimensions for each pattern
The framework is demonstrated using:
- AnthroProtect Dataset: 24,000 multispectral Sentinel-2 images of the Fennoscandia region, labeled as either protected or anthropogenic areas
- CORINE Land Cover: Well-understood land cover classification with 44 classes
The CNE metric reveals patterns that confidently contribute to naturalness:
| Pattern | CNE Metric | Distribution% |
|---|---|---|
| Moors and heathland | 1.00 | 13.2 |
| Peat bogs | 0.81 | 6.1 |
| Bare rock | 0.65 | 6.8 |
| Broad-leaved forest | 0.61 | 13.4 |
| Sparsely vegetated areas | 0.49 | 24.1 |
| Coniferous forest | 0.44 | 18.2 |
| Watercourses | 0.23 | 0.2 |
| Glaciers and perpetual snow | 0.21 | 1.1 |
| Natural grassland | 0.19 | 0.05 |
| Water bodies | 0.18 | 5.2 |
torch>=1.7.0
torchvision>=0.8.0
numpy>=1.19.0
pandas>=1.1.0
tifffile>=2020.9.3
scikit-learn>=0.23.0
tqdm>=4.50.0
plotly>=4.14.0
matplotlib>=3.3.0
The main script naturalness_assessment.py provides a complete implementation of the CNE framework:
# Example configuration
config = {
# Data settings
'csv_file': 'infos.csv',
'image_folder': 'data/anthroprotect/tiles/s2',
'target_folder': 'data/anthroprotect/new_masks',
'train_ratio': 0.8,
'batch_size': 4,
# Model settings
'model_type': 'deeplabv3',
'input_channels': 3,
'output_classes': 43, # CORINE land cover classes
'device': 'cuda' if torch.cuda.is_available() else 'cpu',
'checkpoint_path': 'checkpoint/model_final.pth',
# MC Dropout settings
'num_samples': 25, # Number of Monte Carlo samples
# Results settings
'results_path': 'results/cne_assessment',
}
# Run the pipeline
from naturalness_assessment import end_to_end_pipeline
results = end_to_end_pipeline(config)-
Segmentation Model Training/Loading:
- Load a pre-trained DeepLabV3 model or train a new one on CORINE land cover data
-
Uncertainty Quantification:
- Generate multiple predictions using MC dropout
- Calculate standard deviation across predictions
- Create uncertainty-aware segmentation masks
-
Explainability through Surrogate Modeling:
- Extract pattern distribution vectors from segmentation outputs
- Train a logistic regression model to classify naturalness
- Extract importance coefficients for each pattern
-
CNE Metric Calculation:
- Combine importance coefficients and uncertainty values
- Normalize to 0-1 scale
- Rank patterns by their confident contribution to naturalness
The framework generates:
- Predicted segmentation masks
- Uncertainty-aware segmentation maps highlighting areas of low confidence
- CNE metric values for each pattern
- Feature importance visualizations
The CNE framework addresses limitations of previous naturalness assessment methods:
- Objectivity: Uses data-driven coefficients instead of hand-crafted weights
- Validity: Encompasses all distinctive patterns in the assessment
- Uncertainty Awareness: Accounts for model confidence in the evaluation
- Quantitative Assessment: Provides a clear metric for pattern importance
If you use this code in your research, please cite:
@article{emam2024cne,
title={Confident Naturalness Explanation (CNE): A Framework to Explain and Assess Patterns Forming Naturalness},
author={Emam, Ahmed and Farag, Mohamed and Roscher, Ribana},
journal={IEEE Geoscience and Remote Sensing Letters},
volume={21},
year={2024},
pages={8500505},
doi={10.1109/LGRS.2024.3365196}
}
This work was supported in part by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under various grants including RO 4839/5-1, SCHM 3322/4-1, and the DFG's Excellence Strategy.
