TerraMind

Model Introduction

TerraMind is an any-to-any generative foundation model for Earth observation data. It jointly processes pixel-level and discrete token-level data and learns cross-modal relationships among radar, optical imagery, elevation, land cover, vegetation indices, geographic coordinates, and text.

Paper: TerraMind: Large-Scale Generative Multimodality for Earth Observation
https://arxiv.org/abs/2504.11171

Model Description

TerraMind was proposed by organizations including IBM Research, the European Space Agency, and Forschungszentrum Jülich. The model was pretrained on approximately 9 million globally distributed, spatiotemporally aligned TerraMesh samples and approximately 500 billion training tokens. It is suitable for cross-modal generation, Earth observation representation learning, land-cover segmentation, water-body identification, vegetation assessment, and Thinking-in-Modalities tasks.

Use Cases

Use Case Description
Multimodal representation Jointly encodes optical, radar, elevation, and other Earth observation modalities.
Any-to-any generation Predicts target-modality tokens such as LULC, NDVI, and radar from available modalities such as Sentinel-2, coordinates, and text.
Dual-scale learning Uses both raw pixel patches and discrete token representations.
Local engineering validation Uses aligned synthetic data to verify the training, inference, evaluation, visualization, and checkpoint workflows.
Multi-GPU training Launches distributed data-parallel training through torchrun.

Usage Instructions

1. OneCode

Experience intelligent, one-click AI4S programming through the OneCode online environment:

Try intelligent, one-click AI4S programming

2. Download and Installation

hf download OneScience-Group/TerraMind --local-dir ./TerraMind
cd TerraMind

Environment Dependencies

Hardware Requirements

  • A GPU or DCU is recommended.
  • A CPU can be used to verify connectivity with the default small-sample configuration; official-scale training and diffusion decoding require large-scale accelerated computing resources.
  • DCU users must install DTK in advance. DTK 25.04.2 or later, or the OneScience-recommended version matching the current cluster, is recommended.

DCU Environment

# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

GPU Environment

# Activate Conda first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

Training Data

This repository uses spatiotemporally aligned synthetic multimodal samples to validate the engineering workflow. The source data preserve TerraMesh's 264×264 spatial dimensions and include 12-channel Sentinel-2 L2A, 13-channel Sentinel-2 L1C, 3-channel RGB, 2-channel Sentinel-1 GRD, 2-channel Sentinel-1 RTC, and single-channel DEM data. The loader jointly crops the 224×224 inputs used by the official model from each source sample and constructs content-dependent discrete tokens for LULC, NDVI, radar, and other modalities from the same region, ensuring dual-scale spatial alignment.

python scripts/fake_data.py

Training

python scripts/train.py

For multi-GPU training, use:

torchrun --nproc_per_node=8 --nnodes=1 --rdzv_id=1000 --rdzv_backend=c10d --max_restarts=0 --master_addr="localhost" --master_port=29500 scripts/train.py

The default configuration only reduces the number of samples, Transformer width, depth, vocabulary, and training epochs; it does not change the source-data or model-input spatial dimensions. During training, the workflow randomly selects input pixel modalities, input token modalities, and target modalities, and randomly samples input patches to simulate the paper's multimodal masked-modeling strategy.

result/checkpoints/terramind.pt
result/training/metrics.json

Trained Weights

This repository does not include synthetic or official weights in weight/. IBM and ESA have published model weights for TerraMind variants including tiny, small, base, and large.

Inference

python scripts/inference.py

Inference loads the training checkpoint and generates LULC, NDVI, and Sentinel-1 GRD tokens conditioned only on Sentinel-2 L2A pixels, coordinate tokens, and text tokens. It saves the cross-modal embeddings and target tokens to:

result/output/predictions.npz

Evaluation and Visualization

python scripts/result.py

The evaluation measures token accuracy for each target modality and cross-modal embedding norms, and generates spatial comparison plots of target and generated tokens. Results on synthetic data only validate the engineering pipeline and do not represent the PANGAEA, generation-quality, or Thinking-in-Modalities metrics reported in the paper.

result/evaluation/metrics.json
result/evaluation/comparison.png

Official OneScience Information

Citation and License

This repository is an independent engineering reproduction based on the publicly available specifications from the TerraMind paper.

Use of this repository's code, the official model weights, and the data remains subject to the licenses and terms of use of their respective projects.


中文说明

模型简介

TerraMind 是面向地球观测数据的任意模态到任意模态生成式基础模型。它联合处理像素级和离散词元级数据,学习雷达、光学影像、高程、土地覆盖、植被指数、地理坐标和文本之间的跨模态关系。

论文《TerraMind:面向地球观测的大规模生成式多模态建模》
https://arxiv.org/abs/2504.11171

模型描述

TerraMind 由包括 IBM Research、欧洲空间局及于利希研究中心在内的机构提出。模型在全球分布、时空对齐的约 9 million 个 TerraMesh 样本和约 500 billion 个训练词元上预训练,适用于跨模态生成、地球观测表征学习、土地覆盖分割、水体识别、植被评估及 Thinking-in-Modalities 任务。

使用场景

使用场景 说明
多模态表征 联合编码光学、雷达、高程及其他地球观测模态。
任意模态到任意模态生成 根据 Sentinel-2、坐标和文本等可用模态预测 LULC、NDVI 和雷达等目标模态的词元。
双尺度学习 同时使用原始像素块和离散词元表征。
本地工程验证 使用对齐的合成数据验证训练、推理(inference)、评估、可视化及模型权重(检查点)(checkpoint)流程。
多 GPU 训练 通过 torchrun 启动分布式数据并行训练。

使用说明

1. OneCode

通过 OneCode 在线环境体验智能一键 AI4S 编程。

体验智能一键 AI4S 编程

2. 下载与安装

hf download OneScience-Group/TerraMind --local-dir ./TerraMind
cd TerraMind

环境依赖

硬件要求

  • 建议使用 GPU 或 DCU。
  • 可使用 CPU 在默认小样本配置下验证连通性。官方规模的训练及扩散解码需要大规模加速计算资源。
  • DCU 用户必须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐的与当前集群匹配的版本。

DCU 环境

# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

GPU 环境

# Activate Conda first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

训练数据

本仓库使用时空对齐的合成多模态样本验证工程流程。源数据保留 TerraMesh 的 264×264 空间尺寸,包括 12 通道 Sentinel-2 L2A、13 通道 Sentinel-2 L1C、3 通道 RGB、2 通道 Sentinel-1 GRD、2 通道 Sentinel-1 RTC 及单通道 DEM 数据。加载器从每个源样本联合裁剪官方模型使用的 224×224 输入,并从同一区域为 LULC、NDVI、雷达及其他模态构建依赖内容的离散词元,确保双尺度空间对齐。

python scripts/fake_data.py

训练

python scripts/train.py

多 GPU 训练使用以下命令。

torchrun --nproc_per_node=8 --nnodes=1 --rdzv_id=1000 --rdzv_backend=c10d --max_restarts=0 --master_addr="localhost" --master_port=29500 scripts/train.py

默认配置仅减少样本数、Transformer 宽度、深度、词表规模及训练轮数,源数据和模型输入的空间尺寸保持不变。训练期间,流程随机选择输入像素模态、输入词元模态及目标模态,并随机采样输入块,以模拟论文的多模态掩码建模策略。

result/checkpoints/terramind.pt
result/training/metrics.json

训练权重

本仓库的 weight/ 中未附带合成或官方权重。IBM 和 ESA 已发布 TerraMind 的 tiny、small、base、large 等变体的模型权重。

推理

python scripts/inference.py

推理加载训练所得的模型权重(检查点),仅以 Sentinel-2 L2A 像素、坐标词元和文本词元为条件,生成 LULC、NDVI 和 Sentinel-1 GRD 词元。跨模态嵌入及目标词元保存至以下路径。

result/output/predictions.npz

评估与可视化

python scripts/result.py

评估计算各目标模态的词元准确率和跨模态嵌入范数,并生成目标词元与生成词元的空间对比图。合成数据结果仅验证工程流程,不代表论文报告的 PANGAEA、生成质量或 Thinking-in-Modalities 指标。

result/evaluation/metrics.json
result/evaluation/comparison.png

OneScience 官方信息

引用与许可证

本仓库是根据 TerraMind 论文公开规范完成的独立工程复现。

使用本仓库的代码、官方模型权重和数据仍须遵守各自项目的许可证及使用条款。

Downloads last month
9
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train OneScience-Group/TerraMind

Paper for OneScience-Group/TerraMind