Skip to content

mperezcarrasco/cloud_shadows_segmentation

Repository files navigation

Deep Learning for Clouds and Cloud Shadow Segmentation in Methane Satellite and Airborne Imaging Spectroscopy πŸ›°οΈ

This repository contains the main code of our paper: Deep Learning for Clouds and Cloud Shadow Segmentation in Methane Satellite and Airborne Imaging Spectroscopy

Overview

The cloud and shadow detection system processes MethaneAIR and MethaneSAT L1B hyperspectral data to generate accurate per-pixel masks for:

  • Clouds ☁️
  • Cloud shadows πŸŒ₯️
  • Dark surfaces πŸŒ‘
  • Background/Clear areas

Repository Structure

β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt                          # Python dependencies
β”œβ”€β”€ Dockerfile                               # Container setup
β”œβ”€β”€ build_container.sh                       # Docker build script
β”œβ”€β”€ run_container.sh                         # Docker run script
β”œβ”€β”€ run_experiment.py                        # Batch experiment orchestrator
β”œβ”€β”€ config/                                  # Experiment configurations
β”‚   β”œβ”€β”€ mair_cs_*.yaml                      # MethaneAIR configs
β”‚   └── msat_cs_*.yaml                      # MethaneSAT configs
β”œβ”€β”€ cloud_shadows_detection/                 # Main package
β”‚   β”œβ”€β”€ train.py                            # Training script
β”‚   β”œβ”€β”€ utils.py                            # Training utilities
β”‚   β”œβ”€β”€ models/                             # Model implementations
β”‚   β”‚   β”œβ”€β”€ build_model.py                  # Model factory
β”‚   β”‚   β”œβ”€β”€ hyperspectral_logreg.py         # Logistic regression
β”‚   β”‚   β”œβ”€β”€ mlp_utils.py                    # MLP utilities
β”‚   β”‚   β”œβ”€β”€ unet.py                         # U-Net architecture
β”‚   β”‚   β”œβ”€β”€ scan.py                         # SCAN attention network
β”‚   β”‚   β”œβ”€β”€ combined_cnn.py                 # Combined CNN
β”‚   β”‚   β”œβ”€β”€ combined_mlp.py                 # Combined MLP
β”‚   β”‚   └── ViT_Segformer.py               # Vision Transformer
β”‚   └── datasets/                           # Data handling
β”‚       β”œβ”€β”€ dataset.py                      # Dataset classes
β”‚       └── dataset_utils.py                # Data utilities
└── checkpoints/                            # Saved model results
    β”œβ”€β”€ mair_cs/                           # MethaneAIR results
    └── msat_cs/                           # MethaneSAT results
└── data/                                  # L1B data
    β”œβ”€β”€ mair_cs/                           # MethaneAIR data
    └── msat_cs/                           # MethaneSAT data

Data

All datasets (MethaneAIR and MethaneSAT hyperspectral imagery with ground truth labels) are available through Harvard Dataverse:

  • Dataset size: ~508 MethaneAIR hyperspectral cubes, ~262 MethaneSAT samples
  • Format: L1B calibrated hyperspectral data with corresponding cloud/shadow masks

Key Results

Our comprehensive evaluation demonstrates state-of-the-art performance across multiple model architectures:

Final Performance Summary

Dataset Best Model Accuracy F1-Score Precision Recall
MethaneAIR Combined CNN 89.42Β±1.20% 78.50Β±3.08% 74.44Β±1.89% 88.97Β±2.77%
MethaneSAT Combined CNN 81.96Β±1.45% 78.80Β±1.28% 78.85Β±0.86% 81.09Β±1.23%

Model Comparison (MethaneAIR Dataset)

Model Accuracy F1 Precision Recall
ILR 73.81Β±4.05 62.07Β±0.86 61.33Β±0.67 72.59Β±1.46
MLP 82.49Β±2.24 71.29Β±1.02 68.24Β±1.04 81.42Β±0.85
U-Net 88.26Β±0.45 76.24Β±1.90 72.59Β±2.13 83.65Β±1.03
SCAN 86.51Β±2.90 74.96Β±0.96 72.17Β±1.60 83.46Β±3.13
Combined CNN 89.42Β±1.20 78.50Β±3.08 74.44Β±1.89 88.97Β±2.77

Environment Setup

Option 1: Local Installation.

We strongly recommend using a virtual environment. Set up a venv environment with:

python3 -m venv hsr
source hsr/bin/activate
pip install -r requirements.txt

Option 2: Docker container.

Alternatively, a docker image is contained in Dockerfile. For a containerized setup, use the provided Docker scripts:

bash build_container.sh
bash run_container.sh

Reproducing Paper Results

The results from our published paper can be fully reproduced using the provided configuration files. Each config file specifies the exact hyperparameters, model architectures, and experimental settings used.

Available Models

  • ilr: Iterative Logistic Regression
  • mlp: Multi-Layer Perceptron
  • unet/unetv1: U-Net convolutional architecture
  • scan: Spectral Channel Attention Network
  • combined_cnn: Combined CNN (best performing)
  • combined_mlp: Combined MLP ensemble

Running Experiments

Single model training:

python cloud_shadows_detection/train.py \
    --data_dir data/mair_cs \
    --model_name combined_cnn \
    --run_dir experiments \
    --lr 5e-4 \
    --norm_type std_full \
    --weighted

Reproduce paper results:

# MethaneAIR experiments
python run_experiment.py --config config/mair_cs_scan.yaml
python run_experiment.py --config config/mair_cs_unet.yaml
python run_experiment.py --config config/mair_cs_mlp.yaml

# MethaneSAT experiments  
python run_experiment.py --config config/msat_cs_scan.yaml
python run_experiment.py --config config/msat_cs_unet.yaml
python run_experiment.py --config config/msat_cs_mlp.yaml

The run_experiment.py script orchestrates batch experiments with parallel execution, automatically handling:

  • 3-fold cross-validation
  • Multiple learning rates and hyperparameter grids
  • Model checkpointing and resumption

Key Parameters

  • --model_name: Model architecture to use
  • --data_dir: Path to dataset (mair_cs or msat_cs)
  • --norm_type: Normalization strategy (std_full or none)
  • --weighted: Use class-weighted loss for imbalanced data
  • --lr: Learning rate (optimized per model in configs)

Citation

@article{PrezCarrasco2025DeepLF,
  title={Deep Learning for Clouds and Cloud Shadow Segmentation in Methane Satellite and Airborne Imaging Spectroscopy},
  author={Manuel P{\'e}rez-Carrasco and Maya Nasr and Sebastien Roche and Christopher Chan Miller and Zhan Zhang and Core Francisco Park and Eleanor Walker and Cecilia Garraffo and Douglas Finkbeiner and Ritesh Gautam and Steve Wofsy},
  journal={ArXiv},
  year={2025},
  volume={abs/2509.19665},
  url={https://api.semanticscholar.org/CorpusID:281505215},
  doi={doi:10.7910/DVN/IKLZOJ}
}

Contact

For questions or feedback, please open an issue on this repository or contact maperezc@udec.cl.

About

Cloud and Shadows Segmentation Algorithms for MethaneAIR and MethaneSAT πŸŒŽπŸ›°οΈ

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages