NibblitSeg v1

Text-prompted part segmentation for 32×32 pixel art. Give it a sprite and some part names, and it labels every pixel.

Project page & demo · Code · Showcase video

NibblitSeg v1

Usage

pip install git+https://github.com/Angais/nibblitseg
from nibblitseg import NibblitSeg, colorize

seg = NibblitSeg.from_pretrained("Angais/NibblitSeg-v1")

out = seg.segment("padlock.png", ["shackle", "body", "keyhole"], force_assign_foreground=True)
print(out["pixel_counts"])          # {'shackle': 146, 'body': 319, 'keyhole': 22}
colorize("padlock.png", out["part_map"]).save("padlock_parts.png")

seg.segment("sign.png", ["text"])["pixel_counts"]             # {'text': 55}
seg.segment("jack_o_lantern.png", ["sword"])["pixel_counts"]  # {'sword': 0}

Files

  • model.safetensors: network weights (fp16, 20.05M params)
  • config.json: architecture, text encoder id, held-out exam metrics

Part names are embedded with the frozen SigLIP text tower google/siglip-base-patch16-224, downloaded on first use.

Model

  • 18-channel pixel-art stem (RGBA, neighbour differences, coordinates), 3-scale conv U-Net, 4 RoPE transformer blocks at the bottleneck, 3-layer query decoder, full-resolution dot-product mask head.
  • Output: logits (K+1, H, W), class 0 = other / background, 1..K = the queried parts.
  • Trained on Nibblit's procedurally rendered sprites with per-pixel part labels; best checkpoint at epoch 10.

Evaluation

Held-out exam of 6,509 sprites never seen in training. Full partition, no subject hint.

Metric Score
Pixel accuracy 89.6%
Mean IoU 84.6
Absent parts → exactly 0 px 94.3%
Single-part query IoU 80.2
Opaque background (canvas acc.) 95.4%
Exam group Sprites Pixel acc. mIoU
Text on signs, labels, screens 1,308 99.4% 98.8
Clocks 336 97.3% 94.7
Groups of identical copies 1,275 94.7% 93.9
Two objects in a spatial relation 984 91.7% 89.8
New combinations of known objects 800 86.7% 76.7
Objects from programs never seen in training 1,816 77.7% 66.3

Limitations

  • Trained and evaluated on 32×32 sprites only.
  • Harder on object types it has never seen (77.7% pixel accuracy on unseen programs).
  • Separates copies you name (ladybug 1…N) but does not count on its own.
  • Names close to a real part can grab it (asking a tree for "wings" returns its leaves). Opaque drop shadows on outside tilesets get labelled as parts unless removed first.

License

CC0 1.0 (public domain). The SigLIP text encoder it uses is Apache-2.0.

Downloads last month
43
Safetensors
Model size
20.1M params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support