TerraCodec (TEC) is a family of pretrained neural compression codecs for multispectral Sentinel-2 satellite imagery. The models compress optical Earth observation data using learned latent representations and entropy coding.
Compared to classical codecs such as JPEG2000 or WebP, TerraCodec achieves 3–10× higher compression at comparable reconstruction quality on multispectral satellite imagery. Temporal models further improve compression by exploiting redundancy across seasonal image sequences of satellite imagery.
This repository contains the FlexTEC variant of TerraCodec.
assets/TEC_TT_architecture.png
FlexTEC builds on the TerraCodec Temporal Transformer (TEC-TT) architecture and introduces flexible-rate compression within a single model.
Instead of training separate checkpoints for different rate–distortion settings, FlexTEC supports multiple compression levels through Latent Repacking and missing token prediction. During training, tokens are randomly masked to simulate different compression budgets. At inference time, the number of transmitted tokens controls the compression level: fewer tokens yield higher compression, while more tokens improve reconstruction quality.
See the paper for additional architectural and training details.
Input Format
Codec type
Expected shape
Example
Image codecs
[B, C, H, W]
[1, 12, 256, 256]
Temporal codecs
[B, T, C, H, W]
[1, 4, 12, 256, 256]
Inputs use 12 Sentinel‑2 L2A spectral bands.
Recommended spatial size: 256×256.
Temporal codecs were pretrained on four seasonal frames, but can process any number of timesteps during inference (higher T increases compute).