Prithvi-EO
Model Introduction
Prithvi-EO-2.0 is a foundation model for multi-temporal Earth observation data. It encodes HLS multispectral time series, image acquisition dates, and geographic locations into unified representations and reconstructs masked spatiotemporal patches through a Masked Autoencoder. It can be used for remote-sensing classification, semantic segmentation, regression, and environmental change monitoring.
Paper: Prithvi-EO-2.0: A Versatile Multi-Temporal Foundation Model for Earth Observation Applications
https://arxiv.org/abs/2412.02732
Model Description
Prithvi-EO-2.0 was jointly proposed by IBM, NASA, and the Jülich Supercomputing Centre. The model was trained on 4.2 million global four-timestamp samples from NASA's Harmonized Landsat Sentinel-2 dataset. It is suitable for disaster response, land-cover and crop mapping, ecosystem dynamics monitoring, and remote-sensing image classification, segmentation, and regression tasks.
Use Cases
| Use Case | Description |
|---|---|
| Multi-temporal representation | Uses a Transformer to jointly encode spatial and temporal information from four time steps. |
| Remote-sensing image reconstruction | Uses a 3D Masked Autoencoder to reconstruct masked multispectral spatiotemporal patches. |
| Spatiotemporal metadata modeling | Integrates year, day of year, latitude, and longitude, with support for randomly dropping metadata during training. |
| Local engineering validation | Uses a small number of synthetic HLS samples 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/PrithviEO --local-dir ./PrithviEO
cd PrithviEO
Environment Dependencies
Hardware Requirements
- A GPU or DCU is recommended.
- A CPU can be used to verify connectivity with the default small-sample configuration; training an official-size model requires 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
# Installation with uv is supported
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
# Installation with uv is supported
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
Training Data
This repository uses a small number of synthetic samples to validate the engineering workflow. The training and test data are stored in data/train.npz and data/test.npz, respectively. The synthetic data preserve the four time steps and six HLS common bands used in the paper. The band order is Blue, Green, Red, Narrow NIR, SWIR1, and SWIR2, and normalization uses the officially published means and standard deviations.
The synthetic data preserve the 4×224×224 spatiotemporal dimensions used for training in the paper, and each sample's complete image tensor has dimensions 6×4×224×224. Only the number of samples, model width, model depth, and number of training epochs are reduced. This setup validates the 3D Patch Embedding, spatiotemporal positional encoding, temporal and location metadata encoding, and MAE training workflow; it does not represent the data distribution or training scale of the official 4.2 million HLS samples.
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 is intended for rapid workflow validation. Formal experiments should use real HLS time series, the official 300M or 600M configuration, and the complete training schedule.
result/checkpoints/prithvi_eo.pt
result/training/metrics.json
Trained Weights
This repository does not include synthetic or official weights in weight/. IBM and NASA have published the Prithvi-EO-2.0 tiny, 100M, 300M, and 600M weights on Hugging Face, including the TL versions with temporal and location encodings:
https://huggingface.co/ibm-nasa-geospatial/Prithvi-EO-2.0-300M-TL
This repository is a reduced, independent engineering implementation. Its model parameter names and dimensions are not compatible with the official weights. To use the official weights, use TerraTorch or the implementation and data preprocessing workflow provided by the official repository.
Inference
python scripts/inference.py
Inference loads the training checkpoint, generates the CLS embedding, spatiotemporal patch embeddings, multi-temporal reconstructions of masked patches, and the mask, and saves them to:
result/output/predictions.npz
Evaluation and Visualization
python scripts/result.py
The evaluation measures masked-patch MSE, full spatiotemporal reconstruction MAE, reconstruction error for each time step, and embedding norms. It also generates comparison plots of the input images, reconstructions, and absolute errors for all four time steps. Results on synthetic data only validate the engineering workflow and do not represent GEO-Bench performance or performance on real downstream tasks reported in the paper.
result/evaluation/metrics.json
result/evaluation/comparison.png
Official OneScience Information
| Platform | OneScience Main Repository | Skills Repository |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
Citation and License
This repository is an independent engineering reproduction based on the publicly available specifications from the Prithvi-EO-2.0 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.
中文说明
模型简介
Prithvi-EO-2.0 是面向多时相地球观测数据的基础模型。它将 HLS 多光谱时间序列、图像获取日期及地理位置编码为统一表征,并通过掩码自编码器重建被遮盖的时空分块。模型可用于遥感(remote sensing)分类、语义分割、回归及环境变化监测。
论文:Prithvi-EO-2.0:适用于多种地球观测应用的多时相基础模型
https://arxiv.org/abs/2412.02732
模型描述
Prithvi-EO-2.0 由 IBM、NASA 和于利希超级计算中心联合提出。模型使用 NASA Harmonized Landsat Sentinel-2 数据集中的 4.2 million 个全球四时相样本训练,适用于灾害响应、土地覆盖及农作物制图、生态系统动态监测,以及遥感图像分类、分割和回归。
使用场景
| 使用场景 | 说明 |
|---|---|
| 多时相表征 | 使用 Transformer 联合编码四个时间步的时空信息。 |
| 遥感影像重建 | 使用 3D 掩码自编码器重建被遮盖的多光谱时空分块。 |
| 时空元数据建模 | 集成年份、年积日、纬度和经度,支持训练期间随机丢弃元数据。 |
| 本地工程验证 | 使用少量合成 HLS 样本验证训练、推理(inference)、评估、可视化及模型权重(检查点)(checkpoint)流程。 |
| 多 GPU 训练 | 通过 torchrun 启动分布式数据并行训练。 |
使用指南
1. OneCode
通过 OneCode 在线环境体验智能一键 AI4S 编程。
2. 下载与安装
hf download OneScience-Group/PrithviEO --local-dir ./PrithviEO
cd PrithviEO
环境依赖
硬件要求
- 建议使用 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
# Installation with uv is supported
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
# Installation with uv is supported
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
训练数据
本仓库使用少量合成样本验证工程流程。训练及测试数据分别存放在 data/train.npz 和 data/test.npz 中。合成数据保留论文所用的四个时间步及六个 HLS 公共波段。波段顺序为 Blue、Green、Red、Narrow NIR、SWIR1 和 SWIR2,归一化使用官方发布的均值和标准差。
合成数据保留论文训练使用的 4×224×224 时空维度,每个样本的完整图像张量维度为 6×4×224×224。仅减少样本数量、模型宽度、模型深度及训练轮数。此设置用于验证 3D 分块嵌入、时空位置编码、时间与位置元数据编码和 MAE 训练流程,无法代表官方 4.2 million 个 HLS 样本的数据分布或训练规模。
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
默认配置用于快速验证流程。正式实验应使用真实的 HLS 时间序列、官方 300M 或 600M 配置及完整的训练计划。
result/checkpoints/prithvi_eo.pt
result/training/metrics.json
训练权重
本仓库未在 weight/ 中附带合成或官方权重。IBM 和 NASA 已在 Hugging Face 发布 Prithvi-EO-2.0 tiny、100M、300M 和 600M 权重,包括带时间及位置编码的 TL 版本。
https://huggingface.co/ibm-nasa-geospatial/Prithvi-EO-2.0-300M-TL
本仓库为缩小规模的独立工程实现,其模型参数名称及维度与官方权重不兼容。若要使用官方权重,请使用 TerraTorch 或官方仓库提供的实现和数据预处理流程。
推理
python scripts/inference.py
推理加载训练的模型权重(检查点),生成 CLS 嵌入、时空分块嵌入、被遮盖分块的多时相重建及掩码,并保存到以下位置。
result/output/predictions.npz
评估与可视化
python scripts/result.py
评估测量掩码分块 MSE、完整时空重建 MAE、各时间步的重建误差及嵌入范数,并生成全部四个时间步的输入影像、重建结果及绝对误差对比图。合成数据结果仅用于验证工程流程,无法代表 GEO-Bench 性能或论文中报告的真实下游任务性能。
result/evaluation/metrics.json
result/evaluation/comparison.png
OneScience 官方信息
| 平台 | OneScience 主仓库 | Skills 仓库 |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
引用与许可证
本仓库基于 Prithvi-EO-2.0 论文中的公开规范进行独立工程复现。
本仓库代码、官方模型权重及数据的使用仍受各自项目的许可证和使用条款约束。
- Downloads last month
- 30