Angais/nibblitseg
소개
Text-prompted part segmentation for 32x32 pixel art
머신러닝측정된 스타 증가
- in 24h
- 기록 수집 중
- in 7 days
- 기록 수집 중
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalNibblitSeg 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 · Weights on Hugging Face · Showcase video
- 20.05M parameters, one forward pass, runs on a laptop GPU or a CPU
- Open vocabulary: part names are embedded with the frozen SigLIP text tower
- Full split (every pixel gets one of your parts) or single-part queries (absent parts come back empty)
Install
pip install git+https://github.com/Angais/nibblitseg
Requires Python 3.9+ and PyTorch. Weights (Angais/NibblitSeg-v1, ~40 MB) and the SigLIP text encoder (google/siglip-base-patch16-224) download on first use.
Use it
from nibblitseg import NibblitSeg, colorize
seg = NibblitSeg.from_pretrained() # CUDA if available, else CPU
# 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}
segment() returns:
| key | value |
|---|---|
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 |
Optional: subject="padlock" adds a subject hint (not needed; scores are the same without it).
Command line
nibblitseg examples/sprites/christmas_tree.png --parts star branches ornaments trunk --all --out tree.png
--all assigns every opaque pixel to one of the parts; leave it off for single-part queries. --model accepts a Hub repo id or a local folder with config.json + model.safetensors.
Examples
python examples/quickstart.py # full split, single part, absent part
python examples/read_clock.py # segment clock hands, measure angles, print the time
The sprites in examples/sprites/ are held-out exam sprites (plus one CC0 potion from Dungeon Crawl Stone Soup, drop shadow removed).
Results
Held-out exam of 6,509 sprites never seen in training. Full partition, no subject hint.
| 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% |
By exam group (per-sprite averages, re-run on 6,519 sprites with ≥ 2 parts):
| 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 |
Clock reading (examples/read_clock.py): 334 of 336 held-out clocks read exactly.
Limitations
- Trained and evaluated on 32×32 sprites only.
- Harder on object types it has never seen (77.7% pixel accuracy on unseen programs).
- It separates copies you name (
ladybug 1…N) but does not count on its own: over-asking (ladybug 1…12) and counting non-empty masks is only 22% exact. - 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.
Layout
nibblitseg/ package: model.py (network), text_encoder.py (SigLIP), infer.py (NibblitSeg), __main__.py (CLI)
examples/ quickstart.py, read_clock.py, sprites/
docs/ GitHub Pages site
Training code is not included in this release.
License
Code and weights are released under CC0 1.0 (public domain). The SigLIP text encoder it downloads (google/siglip-base-patch16-224) is Apache-2.0.
관련 프로젝트 살펴보기
불러오는 중…
