TerraMind-1.0-Tokenizer-Diffusers-Collections
Collection
6 items
•
Updated
This repository provides the NDVI tokenizer checkpoint from TerraMind 1.0.
1256x256vit_b_encFSQ (codebook_size=8-8-8-6-5, latent_dim=5)The tokenizer uses native diffusers patterns: ModelMixin, ConfigMixin, from_pretrained, and from_config.
from huggingface_hub import snapshot_download
import torch
import sys
# Download model repository
model_dir = snapshot_download("BiliSakura/TerraMind-1.0-Tokenizer-NDVI")
# Expose local module, then load (diffusers-style)
sys.path.insert(0, model_dir)
from terramind_tokenizer import TerraMindTokenizer
# Load from path or Hub ID
tokenizer = TerraMindTokenizer.from_pretrained(
model_dir, # or "BiliSakura/TerraMind-1.0-Tokenizer-NDVI"
torch_dtype=torch.float32,
device="cpu",
)
# NDVI input: [B, 1, 256, 256]
x = torch.randn(1, 1, 256, 256)
tokens = tokenizer.tokenize(x)
print(tokens.shape) # [1, 16, 16]
# Encode returns (quant, code_loss, tokens)
quant, code_loss, tokens = tokenizer.encode(x)
You can load via diffusers AutoModel or the specific TerraMindTokenizer class with trust_remote_code=True:
from diffusers import AutoModel
import torch
# Option 1: AutoModel (auto-detects from config)
tokenizer = AutoModel.from_pretrained(
"BiliSakura/TerraMind-1.0-Tokenizer-NDVI",
trust_remote_code=True,
torch_dtype=torch.float32,
device="cpu",
)
# Option 2: TerraMindTokenizer (explicit class)
from terramind_tokenizer import TerraMindTokenizer
tokenizer = TerraMindTokenizer.from_pretrained(
"BiliSakura/TerraMind-1.0-Tokenizer-NDVI",
torch_dtype=torch.float32,
device="cpu",
)
# Same API: tokenize(), encode()
x = torch.randn(1, 1, 256, 256)
tokens = tokenizer.tokenize(x)
Security:
trust_remote_code=Trueruns code from the Hub. Only use with repos you trust. For production, pin a specific revision:revision="abc123def456"(commit hash after your changes).
ModelMixin and ConfigMixin for standard from_pretrained / from_config / save_pretrained.model.safetensors and diffusion_pytorch_model.safetensors weights.tokenize(), encode(), and forward().If you use TerraMind in your research, please cite:
@article{jakubik2025terramind,
title={TerraMind: Large-Scale Generative Multimodality for Earth Observation},
author={Jakubik, Johannes and Yang, Felix and Blumenstiel, Benedikt and Scheurer, Erik and Sedona, Rocco and Maurogiovanni, Stefano and Bosmans, Jente and Dionelis, Nikolaos and Marsocci, Valerio and Kopp, Niklas and others},
journal={IEEE/CVF International Conference on Computer Vision (ICCV)},
year={2025}
}