BiliSakura / RSBuilding-ViT-B

huggingface.co
Total runs: 6
24-hour runs: 0
7-day runs: 0
30-day runs: -7
Model's Last Updated: February 05 2026
feature-extraction

Introduction of RSBuilding-ViT-B

Model Details of RSBuilding-ViT-B

RSBuilding-ViT-B

HuggingFace Transformers version of RSBuilding ViT-Base model (ViTSAM_Normal), converted from MMCV format to SamVisionModel format.

Source
Model Information
  • Architecture : Vision Transformer Base (SAM-style)
  • Hidden Size : 768
  • Number of Layers : 12
  • Number of Attention Heads : 12
  • MLP Dimension : 3072
  • Image Size : 512×512
  • Patch Size : 16×16
  • Window Size : 7
  • Global Attention Indexes : [2, 5, 8, 11]
Important Notes
Missing Neck Module Keys (Expected)

When loading this model, you may see messages about missing neck module keys (typically ~6 keys). This is expected and normal.

What is the neck module?

  • The neck module is a channel reduction layer that reduces ViT output from 768 channels to 256 channels
  • It consists of: Conv1x1 → LayerNorm → Conv3x3 → LayerNorm
  • Purpose: Improves efficiency and prepares features for downstream tasks (mask decoder, etc.)

Why they're missing:

  • The source checkpoint (ViTSAM_Normal) may not include neck/channel_reduction weights
  • The HuggingFace SamVisionModel expects a neck module as part of its architecture
  • Missing neck weights will be initialized using HuggingFace's default initialization

Action required:

  • For inference: The model will work, but you may want to fine-tune the neck module on your downstream task
  • For best results: Consider initializing neck weights from a pretrained SAM checkpoint or fine-tuning them
Missing Buffer Keys (Expected)

You may also see messages about missing buffer keys. These are buffers computed dynamically:

  • relative_position_index : Precomputed index mapping for window attention
  • relative_coords_table : Precomputed coordinate table

Action required: None. These are computed automatically during initialization.

Quick Start
Installation
pip install transformers torch pillow
Inference Example
from transformers import SamVisionModel, AutoImageProcessor
from PIL import Image
import torch

# Load model and processor
model = SamVisionModel.from_pretrained("BiliSakura/RSBuilding-ViT-B")
processor = AutoImageProcessor.from_pretrained("BiliSakura/RSBuilding-ViT-B")

# Load and process image
image = Image.open("your_image.jpg")
inputs = processor(image, return_tensors="pt")

# Forward pass
with torch.no_grad():
    outputs = model(**inputs)

# Get features
# outputs.last_hidden_state: (batch_size, num_patches, hidden_size)
# outputs.pooler_output: (batch_size, hidden_size) - pooled representation
features = outputs.last_hidden_state
pooled_features = outputs.pooler_output

print(f"Feature shape: {features.shape}")
print(f"Pooled feature shape: {pooled_features.shape}")
Feature Extraction for Downstream Tasks
from transformers import SamVisionModel, AutoImageProcessor
import torch

model = SamVisionModel.from_pretrained("BiliSakura/RSBuilding-ViT-B")
processor = AutoImageProcessor.from_pretrained("BiliSakura/RSBuilding-ViT-B")

# Process image
image = Image.open("your_image.jpg")
inputs = processor(image, return_tensors="pt")

# Extract features
with torch.no_grad():
    outputs = model(**inputs)
    
# Use pooled features for classification/regression
features = outputs.pooler_output  # Shape: (1, 768)

# Or use last hidden state for dense prediction tasks
spatial_features = outputs.last_hidden_state  # Shape: (1, num_patches, 768)

# Access neck output (after channel reduction to 256)
# Note: This requires accessing model internals
neck_output = model.vision_encoder.neck(outputs.last_hidden_state)  # Shape: (1, 256, H, W)
Fine-tuning the Neck Module

If you need to fine-tune the neck module:

from transformers import SamVisionModel
import torch

model = SamVisionModel.from_pretrained("BiliSakura/RSBuilding-ViT-B")

# Option 1: Freeze backbone, train only neck
for param in model.vision_encoder.encoder.parameters():
    param.requires_grad = False
for param in model.vision_encoder.neck.parameters():
    param.requires_grad = True

# Option 2: Initialize neck from pretrained SAM
from transformers import SamVisionModel as PretrainedSAM
pretrained_sam = PretrainedSAM.from_pretrained("facebook/sam-vit-base")
model.vision_encoder.neck.load_state_dict(pretrained_sam.vision_encoder.neck.state_dict())
Model Configuration

The model uses the following configuration:

  • hidden_size : 768
  • num_hidden_layers : 12
  • num_attention_heads : 12
  • mlp_dim : 3072
  • image_size : 512
  • patch_size : 16
  • window_size : 7
  • output_channels : 256 (neck output)
  • global_attn_indexes : [2, 5, 8, 11]
Citation

If you use this model, please cite the original RSBuilding paper:

@article{wangRSBuildingGeneralRemote2024a,
  title = {{{RSBuilding}}: {{Toward General Remote Sensing Image Building Extraction}} and {{Change Detection With Foundation Model}}},
  shorttitle = {{{RSBuilding}}},
  author = {Wang, Mingze and Su, Lili and Yan, Cilin and Xu, Sheng and Yuan, Pengcheng and Jiang, Xiaolong and Zhang, Baochang},
  year = {2024},
  journal = {IEEE Transactions on Geoscience and Remote Sensing},
  volume = {62},
  pages = {1--17},
  issn = {1558-0644},
  doi = {10.1109/TGRS.2024.3439395},
  keywords = {Building extraction,Buildings,change detection (CD),Data mining,Feature extraction,federated training,foundation model,Image segmentation,Remote sensing,remote sensing images,Task analysis,Training}
}

Runs of BiliSakura RSBuilding-ViT-B on huggingface.co

6
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
-7
30-day runs

More Information About RSBuilding-ViT-B huggingface.co Model

More RSBuilding-ViT-B license Visit here:

https://choosealicense.com/licenses/apache-2.0

RSBuilding-ViT-B huggingface.co

RSBuilding-ViT-B huggingface.co is an AI model on huggingface.co that provides RSBuilding-ViT-B's model effect (), which can be used instantly with this BiliSakura RSBuilding-ViT-B model. huggingface.co supports a free trial of the RSBuilding-ViT-B model, and also provides paid use of the RSBuilding-ViT-B. Support call RSBuilding-ViT-B model through api, including Node.js, Python, http.

RSBuilding-ViT-B huggingface.co Url

https://huggingface.co/BiliSakura/RSBuilding-ViT-B

BiliSakura RSBuilding-ViT-B online free

RSBuilding-ViT-B huggingface.co is an online trial and call api platform, which integrates RSBuilding-ViT-B's modeling effects, including api services, and provides a free online trial of RSBuilding-ViT-B, you can try RSBuilding-ViT-B online for free by clicking the link below.

BiliSakura RSBuilding-ViT-B online free url in huggingface.co:

https://huggingface.co/BiliSakura/RSBuilding-ViT-B

RSBuilding-ViT-B install

RSBuilding-ViT-B is an open source model from GitHub that offers a free installation service, and any user can find RSBuilding-ViT-B on GitHub to install. At the same time, huggingface.co provides the effect of RSBuilding-ViT-B install, users can directly use RSBuilding-ViT-B installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

RSBuilding-ViT-B install url in huggingface.co:

https://huggingface.co/BiliSakura/RSBuilding-ViT-B

Url of RSBuilding-ViT-B

RSBuilding-ViT-B huggingface.co Url

Provider of RSBuilding-ViT-B huggingface.co

BiliSakura
ORGANIZATIONS

Other API from BiliSakura

huggingface.co

Total runs: 130
Run Growth: 98
Growth Rate: 75.38%
Updated:February 16 2026
huggingface.co

Total runs: 26
Run Growth: -15
Growth Rate: -57.69%
Updated:February 16 2026
huggingface.co

Total runs: 16
Run Growth: 8
Growth Rate: 50.00%
Updated:March 09 2026
huggingface.co

Total runs: 8
Run Growth: -14
Growth Rate: -175.00%
Updated:March 09 2026
huggingface.co

Total runs: 6
Run Growth: 1
Growth Rate: 16.67%
Updated:March 09 2026
huggingface.co

Total runs: 2
Run Growth: -5
Growth Rate: -250.00%
Updated:March 09 2026