THOMAS: Transformer for Harmonized Observation via Masked Autoencoding on Sentinel imagery

THOMAS is a ViT-Small encoder (about 22M parameters) pretrained from random initialization with a masked autoencoder (MAE) on about 930,000 unlabeled Sentinel-2 RGB images. Binary wildfire classification (fire / no fire) is used to validate the learned features.

Status: research in progress.

Intended uses

  • Extracting image embeddings (384 dimensions) from Sentinel-2 RGB tiles
  • Starting point for fine-tuning on remote sensing tasks
  • Research on self-supervised learning for Earth observation

Out of scope: operational fire detection, emergency response or any safety-critical decision. Performance on other sensors, band combinations or tasks has not been established here.

Architecture

Encoder Decoder (pretraining only)
Transformer blocks 12 4
Width 384 192
Attention heads 6 6
Tokens per image 257 1,025
  • Input: 512 x 512 RGB
  • Patch size: 16 x 16 (1,024 patches)
  • Positional embedding: fixed 2D sine-cosine
  • Mask ratio: 0.75
  • Embedding: class token output, with all patches visible at inference

Training data

About 930,000 Sentinel-2 images (COPERNICUS/S2_SR_HARMONIZED) collected through Google Earth Engine, RGB bands only. NASA FIRMS VIIRS active fire records were used to choose fire locations and dates. The corpus was designed as roughly 25% fire-event and 75% non-fire imagery.

Training procedure

Setting Value
Loss Mean squared error on masked patches; targets are RGB scaled to [0, 1]
Optimizer AdamW, betas (0.9, 0.95), weight decay 0.05
Base learning rate 1.5e-4
Schedule 20-epoch linear warm-up, then cosine decay
Batch size 128
Augmentation Random horizontal flip
Precision Mixed
Early stopping Patience 15, minimum improvement 1e-4
Epochs Stopped at 46; epoch 31 retained
Hardware One NVIDIA L40 (48 GB)

Evaluation

Linear probe (frozen encoder, linear classifier) on a test split of 86,444 tiles:

Metric Value
Accuracy 95.50%
AUC 0.9915
Fire recall 0.94
No-fire recall 0.97

Fine-tuned with 1,000 labeled tiles (500 per class), the model reached 95.91% accuracy on the same test split at a 0.5 threshold.

Limitations

  • The labeled tiles, including the test split, come from the pretraining pool. The encoder saw these images without labels during pretraining, so results may overstate performance on unseen imagery.
  • Only RGB bands are used. Near-infrared and shortwave infrared bands are not.
  • At a 0.5 threshold, the linear probe misses more fires (2,609) than it raises false alarms (1,280).
  • Thin structures such as roads and field edges are blurred in reconstructions.

How to use

Install the requirements:

pip install torch torchvision huggingface_hub pillow numpy

Download the code and import THOMAS:

import sys
from huggingface_hub import snapshot_download
 
repo = snapshot_download(
    "reshma-merin-thomas/Transformer-for-Harmonized-Observation-via-Masked-Autoencoding-on-Sentinel-imagery",
    allow_patterns=["*.py", "*.pt"],
)
sys.path.insert(0, repo)
 
import thomas
 
model = thomas.load(weights_path=f"{repo}/mae_vit_small_best.pt")
embedding = thomas.embed(model, "my_tile.png")  # shape: (1, 384)

The embedding can be used as input to a classifier. These weights are the pretrained encoder and do not predict fire / no fire on their own.

Using the data

The dataset is stored as .tar shards under data/. data_example.py reads images from one shard:

python data_example.py
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Dataset used to train reshma-merin-thomas/Transformer-for-Harmonized-Observation-via-Masked-Autoencoding-on-Sentinel-imagery