AnySat: An Earth Observation Model for Any Resolutions, Scales, and Modalities
18
15 commits
2 linked in READMEs
updated Jan 7, 2025
Guillaume Astruc, Nicolas Gonthier, Clement Mallet, Loic Landrieu
For more details and results, please check out our github and project page.
AnySat is a versatile Earth Observation model designed to handle diverse data across resolutions, scales, and modalities. Using a scale-adaptive joint embedding predictive architecture (JEPA), AnySat can train in a self-supervised manner on highly heterogeneous datasets.
We train a single AnySat model on GeoPlex, a collection of 5 multimodal datasets spanning 11 sensors with varying characteristics. In fine-tuning or linear probing, AnySat achieves SOTA or near-SOTA performance for land cover segmentation, crop type classification, change detection, tree species identification, and flood mapping.
Check out our demo notebook or huggingface page for more details.
import torch
AnySat = torch.hub.load('gastruc/anysat', 'anysat', pretrained=True, flash_attn=False)
Set flash_attn=True if you have flash-attn module installed. It is not required and only impacts memory and speed.
Arrange your data in a dictionary with any of the following keys:
| Dataset | Description | Tensor Size | Channels | Resolution |
|---|---|---|---|---|
| aerial | Single date tensor | Bx4xHxW | RGB, NiR | 0.2m |
| aerial-flair | Single date tensor | Bx5xHxW | RGB, NiR, Elevation | 0.2m |
| spot | Single date tensor | Bx3xHxW | RGB | 1m |
| naip | Single date tensor | Bx4xHxW | RGB | 1.25m |
| s2 | Time series tensor | BxTx10xHxW | B2, B3, B4, B5, B6, B7, B8, B8a, B11, B12 | 10m |
| s1-asc | Time series tensor | BxTx2xHxW | VV, VH | 10m |
| s1 | Time series tensor | BxTx3xHxW | VV, VH, Ratio | 10m |
| alos | Time series tensor | BxTx3xHxW | HH, HV, Ratio | 30m |
| l7 | Time series tensor | BxTx6xHxW | B1, B2, B3, B4, B5, B7 | 30m |
| l8 | Time series tensor | BxTx11xHxW | B8, B1, B2, B3, B4, B5, B6, B7, B9, B10, B11 | 10m |
| modis | Time series tensor | BxTx7xHxW | B1, B2, B3, B4, B5, B6, B7 | 250m |
Note that time series requires a _dates companion tensor containing the day of the year: 01/01 = 0, 31/12=364.
Example Input for a tile of 60x60m and a batch size of B:
data = {
"aerial": ... #Tensor of size [B, 4, 300, 300] : 4 channels, 300x300 pixels at 20cm res
"spot": ... #Tensor of size [B, 3, 60, 60]: 3 channels, 60x60 pixels at 1m res
"s2": ... #Tensor of size [B, 12, 10, 6, 6] : 12 dates, 10 channels, 6x6 pixels at 10m res
"s2_dates": ... #Tensor of size [B, 12] : 12 dates
}
Ensure that the spatial extent of each modality multiplied by its resolution is consistent.
Decide on:
'tile': Single vector per tile'patch': A vector per patch'dense': A vector per sub-patch'all': a tuple with all three outputsThe sub patches are 1x1 pixels for time series and 10x10 pixels for VHR images. If using output='dense', specify the output_modality.
Example use:
features = AnySat(data, scale=10, output='tile') #tensor of size [D,]
features = AnySat(data, scale=10, output='patch') #tensor of size [D,6,6]
features = AnySat(data, scale=20, output='patch') #tensor of size [D,3,3]
features = AnySat(data, scale=20, output='dense', output_modality='aerial') #tensor of size [D,30,30]
Explanation for the size of the dense map: d=10 for 'aerial' which has a 0.2m resolution, the sub-patches are 2x2 m.
# clone project
git clone https://github.com/gastruc/anysat
cd anysat
# [OPTIONAL] create conda environment
conda create -n anysat python=3.9
conda activate anysat
# install requirements
pip install -r requirements.txt
# Create data folder where you can put your datasets
mkdir data
# Create logs folder
mkdir logs
To load the model locally, you can use the following code:
from hubconf import AnySat
AnySat = AnySat.from_pretrained('base', flash_attn=False) #Set flash_attn=True if you have flash-attn module installed
#For now, only base is available.
#device = "cuda" If you want to run on GPU default is cpu
Every experience of the paper has its config file. Feel free to explore configs/exp folder.
# Run AnySat pretraining on GeoPlex
python src/train.py exp=GeoPlex_AnySAT
# Run AnySat finetuning on BraDD-S1TS
python src/train.py exp=BraDD_AnySAT_FT
# Run AnySat linear probing on BraDD-S1TS
python src/train.py exp=BraDD_AnySAT_LP
Our implementation already supports 9 datasets:
TreeSatAI-TS
PASTIS-HD
FLAIR
PLANTED
S2NAIP-URBAN
BraDD-S1TS
SICKLE
TimeSen2Crop
Sen1Flood11
Please use the following bibtex:
@article{astruc2024anysat,
title={{AnySat: An Earth} Observation Model for Any Resolutions, Scales, and Modalities},
author={Astruc, Guillaume and Gonthier, Nicolas and Mallet, Clement and Landrieu, Loic},
journal={arXiv preprint arXiv:2412.14123},
year={2024}
}
AnySat: An Earth Observation Model for Any Resolutions, Scales, and Modalities
18
15 commits
2 linked in READMEs
updated Jan 7, 2025
Guillaume Astruc, Nicolas Gonthier, Clement Mallet, Loic Landrieu
For more details and results, please check out our github and project page.
AnySat is a versatile Earth Observation model designed to handle diverse data across resolutions, scales, and modalities. Using a scale-adaptive joint embedding predictive architecture (JEPA), AnySat can train in a self-supervised manner on highly heterogeneous datasets.
We train a single AnySat model on GeoPlex, a collection of 5 multimodal datasets spanning 11 sensors with varying characteristics. In fine-tuning or linear probing, AnySat achieves SOTA or near-SOTA performance for land cover segmentation, crop type classification, change detection, tree species identification, and flood mapping.
Check out our demo notebook or huggingface page for more details.
import torch
AnySat = torch.hub.load('gastruc/anysat', 'anysat', pretrained=True, flash_attn=False)
Set flash_attn=True if you have flash-attn module installed. It is not required and only impacts memory and speed.
Arrange your data in a dictionary with any of the following keys:
| Dataset | Description | Tensor Size | Channels | Resolution |
|---|---|---|---|---|
| aerial | Single date tensor | Bx4xHxW | RGB, NiR | 0.2m |
| aerial-flair | Single date tensor | Bx5xHxW | RGB, NiR, Elevation | 0.2m |
| spot | Single date tensor | Bx3xHxW | RGB | 1m |
| naip | Single date tensor | Bx4xHxW | RGB | 1.25m |
| s2 | Time series tensor | BxTx10xHxW | B2, B3, B4, B5, B6, B7, B8, B8a, B11, B12 | 10m |
| s1-asc | Time series tensor | BxTx2xHxW | VV, VH | 10m |
| s1 | Time series tensor | BxTx3xHxW | VV, VH, Ratio | 10m |
| alos | Time series tensor | BxTx3xHxW | HH, HV, Ratio | 30m |
| l7 | Time series tensor | BxTx6xHxW | B1, B2, B3, B4, B5, B7 | 30m |
| l8 | Time series tensor | BxTx11xHxW | B8, B1, B2, B3, B4, B5, B6, B7, B9, B10, B11 | 10m |
| modis | Time series tensor | BxTx7xHxW | B1, B2, B3, B4, B5, B6, B7 | 250m |
Note that time series requires a _dates companion tensor containing the day of the year: 01/01 = 0, 31/12=364.
Example Input for a tile of 60x60m and a batch size of B:
data = {
"aerial": ... #Tensor of size [B, 4, 300, 300] : 4 channels, 300x300 pixels at 20cm res
"spot": ... #Tensor of size [B, 3, 60, 60]: 3 channels, 60x60 pixels at 1m res
"s2": ... #Tensor of size [B, 12, 10, 6, 6] : 12 dates, 10 channels, 6x6 pixels at 10m res
"s2_dates": ... #Tensor of size [B, 12] : 12 dates
}
Ensure that the spatial extent of each modality multiplied by its resolution is consistent.
Decide on:
'tile': Single vector per tile'patch': A vector per patch'dense': A vector per sub-patch'all': a tuple with all three outputsThe sub patches are 1x1 pixels for time series and 10x10 pixels for VHR images. If using output='dense', specify the output_modality.
Example use:
features = AnySat(data, scale=10, output='tile') #tensor of size [D,]
features = AnySat(data, scale=10, output='patch') #tensor of size [D,6,6]
features = AnySat(data, scale=20, output='patch') #tensor of size [D,3,3]
features = AnySat(data, scale=20, output='dense', output_modality='aerial') #tensor of size [D,30,30]
Explanation for the size of the dense map: d=10 for 'aerial' which has a 0.2m resolution, the sub-patches are 2x2 m.
# clone project
git clone https://github.com/gastruc/anysat
cd anysat
# [OPTIONAL] create conda environment
conda create -n anysat python=3.9
conda activate anysat
# install requirements
pip install -r requirements.txt
# Create data folder where you can put your datasets
mkdir data
# Create logs folder
mkdir logs
To load the model locally, you can use the following code:
from hubconf import AnySat
AnySat = AnySat.from_pretrained('base', flash_attn=False) #Set flash_attn=True if you have flash-attn module installed
#For now, only base is available.
#device = "cuda" If you want to run on GPU default is cpu
Every experience of the paper has its config file. Feel free to explore configs/exp folder.
# Run AnySat pretraining on GeoPlex
python src/train.py exp=GeoPlex_AnySAT
# Run AnySat finetuning on BraDD-S1TS
python src/train.py exp=BraDD_AnySAT_FT
# Run AnySat linear probing on BraDD-S1TS
python src/train.py exp=BraDD_AnySAT_LP
Our implementation already supports 9 datasets:
TreeSatAI-TS
PASTIS-HD
FLAIR
PLANTED
S2NAIP-URBAN
BraDD-S1TS
SICKLE
TimeSen2Crop
Sen1Flood11
Please use the following bibtex:
@article{astruc2024anysat,
title={{AnySat: An Earth} Observation Model for Any Resolutions, Scales, and Modalities},
author={Astruc, Guillaume and Gonthier, Nicolas and Mallet, Clement and Landrieu, Loic},
journal={arXiv preprint arXiv:2412.14123},
year={2024}
}