s2_res / README.md
riccardode's picture frankaisabell's picture
Add MODIS-to-S2 checkpoint, examples and validation data (#1)
67d058a
|
Raw History Blame Contribute Delete
2.56 kB
---
language:
- en
tags:
- remote-sensing
- earth-observation
- ndvi
- sentinel-2
- modis
pretty_name: MODIS to Sentinel-2 NDVI
---
# MODIS to Sentinel-2 NDVI
This checkpoint reconstructs Sentinel-2 NDVI on a 20 m grid using prior Sentinel-1 and Sentinel-2 observations, target-day MODIS at 250 m, MTG and land cover. Each prediction covers 5.12 × 5.12 km. This release freezes the best completed model at export time, trained on 821 scenes and selected on 277 validation scenes.
The package includes the weights, inference code, ten examples and reference predictions. The inputs are ready to use; no satellite downloads or HPC access are needed.
## Try an example
Download and extract [demo_bundle.zip](demo_bundle.zip), then open a terminal in the extracted directory. Python 3.11 is the tested version.
```bash
python3 -m venv .venv
source .venv/bin/activate
python -m pip install torch==2.11.0 --index-url https://download.pytorch.org/whl/cpu
python -m pip install -r requirements.txt
python -m modis_s2.predict \
--sample demo/france_south_x-1_y-1_2025-06-18 \
--output prediction.tif
```
The output is a georeferenced, single-band NDVI image with values between −1 and 1. Use a `.npy` filename for a NumPy array instead. The default is CPU inference in float32. For an NVIDIA GPU, install the corresponding PyTorch build and add `--device cuda --precision bf16`.
## Validation data
The full validation set is provided in separate archives (5.51 GB). From the package directory:
```bash
python -m modis_s2.download_validation --output data/validation
python -m modis_s2.evaluate --data data/validation --output metrics.json
```
The downloader uses the pinned data revision and verifies archive and sample checksums. To use archives already downloaded from the repository, add `--local-shards .`.
The original CUDA/bfloat16 evaluation over all 277 scenes gave RMSE **0.06960**, MAE **0.04583**, SSIM **0.90465** and PSNR **29.168 dB** on valid target pixels. These scenes were used for model selection, so this is a validation result. Float32 CPU results can differ slightly from the original GPU results. `reference_metrics.json` contains the original evaluation; `test_results.json` records the portable package checks.
Each scene has separate `inputs.npz`, `target.npz` and `metadata.json` files. Inference reads the inputs and georeferencing only. The target and its validity mask are used for evaluation. The exported inputs are already normalized. See [INPUTS.md](INPUTS.md) for the tensor layout and preprocessing details.