Views
No views yet
config.json, model.safetensors, preprocessor, and remote code) for encoder feature extraction on optical remote sensing imagery.architecture: s4p_backbone and expose the s5-feature-extraction pipeline. They are encoder-only weights (not UPerNet segmentation or MoE-MDF heads).modeling_s5.py, processor, pipeline) and load with trust_remote_code=True.| Folder | Backbone | Hidden size | Layers | Heads | Patch | Image size | Original file |
|---|---|---|---|---|---|---|---|
ViT-B | ViT-Base | 768 | 12 | 12 | 16 | 512 | vit_b_s4p.pth |
ViT-L | ViT-Large | 1024 | 24 | 16 | 16 | 512 | vit_l_s4p.pth |
.pth files were converted and removed from this directory.do_resize: false. Pass RGB images at native resolution; ImageNet mean/std normalization is applied when enabled.1from transformers import pipeline
2import numpy as np
3
4REPO = "/path/to/S5-transformers"
5
6pipe = pipeline(
7 task="s5-feature-extraction",
8 model=f"{REPO}/ViT-B",
9 trust_remote_code=True,
10)
11
12image = np.random.randint(0, 255, (512, 512, 3), dtype=np.uint8)
13
14# Global pooled features
15features = pipe(image, pool=True, return_tensors=True)
16print(features.shape) # [1, 768] for ViT-B, [1, 1024] for ViT-L
17
18# Dense feature map
19featmap = pipe(image, pool=False, return_tensors=True)
20print(featmap.shape) # [1, 768, 32, 32] for ViT-B, [1, 1024, 32, 32] for ViT-L1pipe = pipeline(
2 task="s5-feature-extraction",
3 model=f"{REPO}/ViT-L",
4 trust_remote_code=True,
5)
6features = pipe(image, pool=True, return_tensors=True)
7print(features.shape) # [1, 1024]1features = pipe(
2 image,
3 pool=True,
4 return_tensors=True,
5 image_processor_kwargs={"do_resize": True},
6)1from transformers import AutoModel, AutoImageProcessor
2
3model = AutoModel.from_pretrained(f"{REPO}/ViT-B", trust_remote_code=True)
4processor = AutoImageProcessor.from_pretrained(f"{REPO}/ViT-B", trust_remote_code=True)do_normalize=True, rescale_factor=1/255). Inputs should be RGB optical imagery.scripts/convert_s5_checkpoint.py from the official release:1python scripts/convert_s5_checkpoint.py \
2 --input-path /path/to/vit_b_s4p.pth \
3 --output-dir /path/to/ViT-B \
4 --clean-outputvit_*_s4p_upernet.pth or s5_vit_*_moe_mdf_seg.pth instead (task: s5-semantic-segmentation).transformers>=4.45.0torch>=2.1.0safetensorsPillownumpy1@article{S5,
2 title={S5: Scalable Semi-Supervised Semantic Segmentation in Remote Sensing},
3 author={Liang Lv and Di Wang and Jing Zhang and Lefei Zhang},
4 journal={arXiv preprint arXiv:2508.12409},
5 year={2025}
6}