Sapiens-2 Segmentation 0.4B (MLX, corrected config)
The same weights as
mlx-community/sapiens2-seg-0.4b-bf16
with a config.json that describes them.
The upstream config carries no architecture fields, so loaders fall back to the
1B defaults (hidden size 1536, 40 blocks) against a 24-block 0.4B checkpoint,
and it names the decode head with the older deconv_* keys. This copy adds the
0.4B geometry and architectures, and renames the head keys:
| field | upstream | here |
|---|---|---|
architectures | absent | ["Sapiens2ForSemanticSegmentation"] |
hidden_size / num_hidden_layers / num_attention_heads | absent | 1024 / 24 / 16 |
intermediate_size / patch_size / image_size | absent | 4096 / 16 / [1024, 768] |
num_labels | absent | 29 |
head_config.deconv_out_channels | [512, 256, 128, 64] | upsample_out_channels |
head_config.deconv_kernel_sizes | [4, 4, 4, 4] | upsample_kernel_sizes |
Weights are byte-for-byte the upstream ones.
Usage
mlx_vlm.extract --model nativ-community/sapiens2-seg-0.4b-bf16 --image person.jpg --output seg.npz
from mlx_vlm import load
from mlx_vlm.extraction import extract
model, processor = load("nativ-community/sapiens2-seg-0.4b-bf16")
result = extract(model, processor, image) # {"segmentation": (H, W)}