Views
No views yet
1256x256vit_b_encFSQ (codebook_size=8-8-8-6-5, latent_dim=5)ModelMixin, ConfigMixin, from_pretrained, and from_config.1from huggingface_hub import snapshot_download
2import torch
3import sys
4
5# Download model repository
6model_dir = snapshot_download("BiliSakura/TerraMind-1.0-Tokenizer-DEM")
7
8# Expose local module, then load (diffusers-style)
9sys.path.insert(0, model_dir)
10from terramind_tokenizer import TerraMindTokenizer
11
12# Load from path or Hub ID
13tokenizer = TerraMindTokenizer.from_pretrained(
14 model_dir, # or "BiliSakura/TerraMind-1.0-Tokenizer-DEM"
15 torch_dtype=torch.float32,
16 device="cpu",
17)
18
19# DEM input: [B, 1, 256, 256]
20x = torch.randn(1, 1, 256, 256)
21tokens = tokenizer.tokenize(x)
22print(tokens.shape) # [1, 16, 16]
23
24# Encode returns (quant, code_loss, tokens)
25quant, code_loss, tokens = tokenizer.encode(x)AutoModel or the specific TerraMindTokenizer class with trust_remote_code=True:1from diffusers import AutoModel
2import torch
3
4# Option 1: AutoModel (auto-detects from config)
5tokenizer = AutoModel.from_pretrained(
6 "BiliSakura/TerraMind-1.0-Tokenizer-DEM",
7 trust_remote_code=True,
8 torch_dtype=torch.float32,
9 device="cpu",
10)
11
12# Option 2: TerraMindTokenizer (explicit class)
13from terramind_tokenizer import TerraMindTokenizer
14tokenizer = TerraMindTokenizer.from_pretrained(
15 "BiliSakura/TerraMind-1.0-Tokenizer-DEM",
16 torch_dtype=torch.float32,
17 device="cpu",
18)
19
20# Same API: tokenize(), encode()
21x = torch.randn(1, 1, 256, 256)
22tokens = 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().1@article{jakubik2025terramind,
2 title={TerraMind: Large-Scale Generative Multimodality for Earth Observation},
3 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},
4 journal={IEEE/CVF International Conference on Computer Vision (ICCV)},
5 year={2025}
6}