NibblitSeg v1: weights, config, model card
Browse files- README.md +77 -0
- config.json +34 -0
- model.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: image-segmentation
|
| 3 |
+
tags:
|
| 4 |
+
- pixel-art
|
| 5 |
+
- open-vocabulary
|
| 6 |
+
- part-segmentation
|
| 7 |
+
- sprites
|
| 8 |
+
library_name: pytorch
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# NibblitSeg v1
|
| 12 |
+
|
| 13 |
+
Text-prompted part segmentation for 32×32 pixel art. Give it a sprite and some part names, and it labels every pixel.
|
| 14 |
+
|
| 15 |
+
**[Project page & demo](https://angais.github.io/nibblitseg/)** · **[Code](https://github.com/Angais/nibblitseg)** · **[Showcase video](https://angais.github.io/nibblitseg/assets/nibblitseg_v1.mp4)**
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
|
| 19 |
+
## Usage
|
| 20 |
+
|
| 21 |
+
```bash
|
| 22 |
+
pip install git+https://github.com/Angais/nibblitseg
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
from nibblitseg import NibblitSeg, colorize
|
| 27 |
+
|
| 28 |
+
seg = NibblitSeg.from_pretrained("Angais/NibblitSeg-v1")
|
| 29 |
+
|
| 30 |
+
out = seg.segment("padlock.png", ["shackle", "body", "keyhole"], force_assign_foreground=True)
|
| 31 |
+
print(out["pixel_counts"]) # {'shackle': 146, 'body': 319, 'keyhole': 22}
|
| 32 |
+
colorize("padlock.png", out["part_map"]).save("padlock_parts.png")
|
| 33 |
+
|
| 34 |
+
seg.segment("sign.png", ["text"])["pixel_counts"] # {'text': 55}
|
| 35 |
+
seg.segment("jack_o_lantern.png", ["sword"])["pixel_counts"] # {'sword': 0}
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
## Files
|
| 39 |
+
|
| 40 |
+
- `model.safetensors`: network weights (fp16, 20.05M params)
|
| 41 |
+
- `config.json`: architecture, text encoder id, held-out exam metrics
|
| 42 |
+
|
| 43 |
+
Part names are embedded with the frozen SigLIP text tower `google/siglip-base-patch16-224`, downloaded on first use.
|
| 44 |
+
|
| 45 |
+
## Model
|
| 46 |
+
|
| 47 |
+
- 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.
|
| 48 |
+
- Output: logits `(K+1, H, W)`, class 0 = other / background, 1..K = the queried parts.
|
| 49 |
+
- Trained on Nibblit's procedurally rendered sprites with per-pixel part labels; best checkpoint at epoch 10.
|
| 50 |
+
|
| 51 |
+
## Evaluation
|
| 52 |
+
|
| 53 |
+
Held-out exam of 6,509 sprites never seen in training. Full partition, no subject hint.
|
| 54 |
+
|
| 55 |
+
| Metric | Score |
|
| 56 |
+
|---|---:|
|
| 57 |
+
| Pixel accuracy | 89.6% |
|
| 58 |
+
| Mean IoU | 84.6 |
|
| 59 |
+
| Absent parts → exactly 0 px | 94.3% |
|
| 60 |
+
| Single-part query IoU | 80.2 |
|
| 61 |
+
| Opaque background (canvas acc.) | 95.4% |
|
| 62 |
+
|
| 63 |
+
| Exam group | Sprites | Pixel acc. | mIoU |
|
| 64 |
+
|---|---:|---:|---:|
|
| 65 |
+
| Text on signs, labels, screens | 1,308 | 99.4% | 98.8 |
|
| 66 |
+
| Clocks | 336 | 97.3% | 94.7 |
|
| 67 |
+
| Groups of identical copies | 1,275 | 94.7% | 93.9 |
|
| 68 |
+
| Two objects in a spatial relation | 984 | 91.7% | 89.8 |
|
| 69 |
+
| New combinations of known objects | 800 | 86.7% | 76.7 |
|
| 70 |
+
| Objects from programs never seen in training | 1,816 | 77.7% | 66.3 |
|
| 71 |
+
|
| 72 |
+
## Limitations
|
| 73 |
+
|
| 74 |
+
- Trained and evaluated on 32×32 sprites only.
|
| 75 |
+
- Harder on object types it has never seen (77.7% pixel accuracy on unseen programs).
|
| 76 |
+
- Separates copies you name (`ladybug 1…N`) but does not count on its own.
|
| 77 |
+
- 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.
|
config.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "nibblitseg",
|
| 3 |
+
"version": "1.0",
|
| 4 |
+
"arch": {
|
| 5 |
+
"text_dim": 768,
|
| 6 |
+
"c0": 96,
|
| 7 |
+
"c1": 192,
|
| 8 |
+
"c2": 320,
|
| 9 |
+
"mask_dim": 128,
|
| 10 |
+
"num_heads": 8,
|
| 11 |
+
"num_bottleneck_layers": 4,
|
| 12 |
+
"num_query_layers": 3
|
| 13 |
+
},
|
| 14 |
+
"siglip_model": "google/siglip-base-patch16-224",
|
| 15 |
+
"train_epoch": 10,
|
| 16 |
+
"params": 20050010,
|
| 17 |
+
"exam_metrics": {
|
| 18 |
+
"n_exam": 6509,
|
| 19 |
+
"full_with_subj_acc": 89.51,
|
| 20 |
+
"full_with_subj_miou": 84.44,
|
| 21 |
+
"full_no_subj_acc": 89.63,
|
| 22 |
+
"full_no_subj_miou": 84.58,
|
| 23 |
+
"full_free_acc": 85.85,
|
| 24 |
+
"full_free_miou": 82.73,
|
| 25 |
+
"jitter_acc": 90.88,
|
| 26 |
+
"jitter_miou": 85.7,
|
| 27 |
+
"single_part_iou": 80.17,
|
| 28 |
+
"single_part_f1": 83.18,
|
| 29 |
+
"distractor_fp_pct": 1.225,
|
| 30 |
+
"distractor_exact_zero_pct": 94.3,
|
| 31 |
+
"opaque_bg_canvas_acc": 95.42,
|
| 32 |
+
"opaque_bg_fg_acc": 90.11
|
| 33 |
+
}
|
| 34 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3a52ce36272c0e19f5cdf76b7b3a733e8215d675a7b4295f42bd0f268ee77e8d
|
| 3 |
+
size 40124828
|