NibblitSeg v1

Text-prompted part segmentation for 32×32 pixel art. Name the parts, and it labels every pixel. 20M parameters, one forward pass, runs on a laptop GPU or a CPU.

Explore

Name the parts. It finds them.

Real outputs on held-out exam sprites the model never saw in training, scored against ground truth. Hover a part to isolate it.

Prompt = these part names, no subject hint.

Capabilities

What it can do

Split a sprite into layers

List every part and each opaque pixel goes to exactly one of them.

Ask for just one part

Everything else stays "other". Parts that aren't there come back empty.

Tell identical copies apart

Prompt ladybug 1, ladybug 2, … and every copy gets its own mask.

Read a clock

Segment the hands, measure their angles. 334 of 336 held-out clocks read exactly.

Quickstart

Run it in three lines

Weights download from Hugging Face on first use. CUDA is used when available, otherwise CPU.

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

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

# name every part: each opaque pixel goes to one of them
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")

# ask for one part; absent parts come back empty
seg.segment("sign.png", ["text"])["pixel_counts"]            # {'text': 55}
seg.segment("jack_o_lantern.png", ["sword"])["pixel_counts"]  # {'sword': 0}
command line
nibblitseg examples/sprites/christmas_tree.png --parts star branches ornaments trunk --all --out tree.png
result dict
part_map      (H, W) int32   0 = other / background, 1..K = index into parts
masks         {part: (H, W) bool}
pixel_counts  {part: int}
probs         (K+1, H, W) float32 softmax

More in examples/: quickstart.py and read_clock.py, with the sprites shown on this page.

Results

Held-out exam

6,509 exam sprites never seen in training. Full partition with no subject hint: the model gets the list of part names and must label every pixel.

89.6%
pixel accuracy
84.6
mean IoU
94.3%
absent parts return exactly 0 px
Exam groupSpritesPixel acc.mIoU
Text on signs, labels, screens1,30899.4%98.8
Clocks33697.3%94.7
Groups of identical copies1,27594.7%93.9
Two objects in a spatial relation98491.7%89.8
New combinations of known objects80086.7%76.7
Objects from programs never seen in training1,81677.7%66.3
Other settingsScore
Single-part query (one name, no subject)80.2 IoU
With a subject hint89.5% acc.
Simulated generator noise (σ = 5/255)90.9% acc.
Opaque background instead of transparency95.4% canvas acc.
Absent-part false-positive pixels1.2%

Group rows are per-sprite averages from a re-run of the exam (6,519 sprites with ≥ 2 parts); headline numbers are from the official evaluation. Clock reading uses a small angle-measuring script on top of the masks.

Limitations

Know before you use it

Built for 32×32

The network is resolution-agnostic, but it was trained and evaluated on 32×32 sprites only.

New object types are harder

On objects from programs it never saw, pixel accuracy drops to 77.7%. Part boundaries on complex sprites can be rough.

It doesn't count by itself

It separates copies when you name them (ladybug 1…N). Over-asking (ladybug 1…12) and counting non-empty masks is only 22% exact.

Close words can bleed

A name that resembles 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.

  • Network 20.05M params: 18-channel pixel-art stem (RGBA, neighbour differences, coordinates), 3-scale conv U-Net, 4 RoPE transformer blocks, 3-layer query decoder, full-resolution mask head.
  • Text part names embedded by the frozen SigLIP text tower (google/siglip-base-patch16-224), downloaded on first use.
  • Training Nibblit's procedurally rendered sprites with per-pixel part labels; best checkpoint at epoch 10.