How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("feature-extraction", model="BiliSakura/DOFA-transformers")
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("BiliSakura/DOFA-transformers", dtype="auto")
Quick Links

DOFA Transformers Models

Self-contained HuggingFace model checkpoints for DOFA.

Each checkpoint subfolder ships remote code for model, processor, and pipeline loading with trust_remote_code=True.

Sentinel-2 9-band defaults (default_wavelengths, default_image_mean, default_image_std) are baked into config.json and preprocessor_config.json.

Available checkpoints

Folder Hidden size Layers Heads
dofa-base-patch16-224/ 768 12 12
dofa-large-patch16-224/ 1024 24 16

Usage

Processors default to do_resize: false. Pass Sentinel-2 stacks at native (H, W, C); the processor rescales values (typically /255) without changing spatial size.

from transformers import pipeline

MODEL = "/path/to/DOFA-transformers/dofa-base-patch16-224"

pipe = pipeline(
    task="dofa-feature-extraction",
    model=MODEL,
    trust_remote_code=True,
)

# Native-resolution patch, e.g. 512×512×9 bands (uint8 or float)
features = pipe(image_array, pool=True, return_tensors=True)

Dense features:

tokens = pipe(image_array, pool=False, return_tensors=True)

Opt in to 224×224 resize (original pretraining size):

features = pipe(
    image_array,
    pool=True,
    return_tensors=True,
    image_processor_kwargs={"do_resize": True},
)

Override Sentinel-2 defaults for other sensors:

features = pipe(
    image_array,
    wavelengths=[...],
    image_mean=[...],
    image_std=[...],
    pool=True,
    return_tensors=True,
)

Test CLI

conda activate rsgen
python test_dofa.py
python test_dofa.py --model dofa-large-patch16-224
python test_dofa.py --model dofa-base-patch16-224 --no-pool

Dependencies

  • transformers
  • timm
  • torch
  • opencv-python (only when resizing inputs with more than 4 channels)
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including BiliSakura/DOFA-transformers

Paper for BiliSakura/DOFA-transformers