sprite-gpt: rectified-flow diffusion for emoji + sprites (32px uncond, 64px class-cond)
Browse files- .gitattributes +1 -0
- README.md +99 -1
- samples_grid.png +3 -0
- sprite-gpt-cond64.pt +3 -0
- sprite-gpt-emoji32.pt +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
samples_grid.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,101 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: cc-by-sa-4.0
|
| 3 |
+
tags:
|
| 4 |
+
- diffusion
|
| 5 |
+
- rectified-flow
|
| 6 |
+
- flow-matching
|
| 7 |
+
- pixel-art
|
| 8 |
+
- emoji
|
| 9 |
+
- sprites
|
| 10 |
+
- image-generation
|
| 11 |
+
- pytorch
|
| 12 |
+
library_name: pytorch
|
| 13 |
+
pipeline_tag: unconditional-image-generation
|
| 14 |
---
|
| 15 |
+
|
| 16 |
+
# sprite-gpt
|
| 17 |
+
|
| 18 |
+
Small pixel-space diffusion models for emoji and game sprites, trained with
|
| 19 |
+
rectified flow (flow matching) on a single RTX 5090. Code:
|
| 20 |
+
[github.com/gmmeyer/sprite-diffusion](https://github.com/gmmeyer/sprite-diffusion)
|
| 21 |
+
|
| 22 |
+
| file | model | params | training |
|
| 23 |
+
|---|---|---|---|
|
| 24 |
+
| `sprite-gpt-cond64.pt` | class-conditional 64px, 31 classes | 55.8M | 95k steps @ bs128 on 24,134 emoji+sprites |
|
| 25 |
+
| `sprite-gpt-emoji32.pt` | unconditional 32px emoji | 29.1M | 60k steps @ bs256 on 8,504 emoji |
|
| 26 |
+
|
| 27 |
+
Both are ADM-style U-Nets (scale-shift GroupNorm conditioning, self-attention
|
| 28 |
+
at 16x16 and 8x8) trained with the rectified-flow objective
|
| 29 |
+
(`x_t = (1-t)·x0 + t·ε`, predict `v = ε − x0`, logit-normal timestep
|
| 30 |
+
sampling). Weights are fp32 EMA (decay 0.9995). Sampling: 50-step Euler ODE;
|
| 31 |
+
the conditional model uses classifier-free guidance (null class = index 31,
|
| 32 |
+
condition dropout 10% at train time; guidance 3 works well).
|
| 33 |
+
|
| 34 |
+

|
| 35 |
+
|
| 36 |
+
## Usage
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
# git clone https://github.com/gmmeyer/sprite-diffusion && cd sprite-diffusion && uv sync
|
| 40 |
+
import torch
|
| 41 |
+
from spritegpt.unet import UNet
|
| 42 |
+
from spritegpt.flow import sample
|
| 43 |
+
from spritegpt.utils import save_image_grid
|
| 44 |
+
|
| 45 |
+
ck = torch.load("sprite-gpt-cond64.pt", map_location="cuda", weights_only=False)
|
| 46 |
+
cfg = ck["config"]
|
| 47 |
+
model = UNet(
|
| 48 |
+
img_size=cfg["img_size"],
|
| 49 |
+
base=cfg["base"],
|
| 50 |
+
ch_mult=tuple(int(c) for c in cfg["ch_mult"].split(",")),
|
| 51 |
+
num_res=cfg["num_res"],
|
| 52 |
+
attn_res=tuple(int(r) for r in cfg["attn_res"].split(",")),
|
| 53 |
+
num_classes=cfg["num_classes"],
|
| 54 |
+
).cuda()
|
| 55 |
+
model.load_state_dict(ck["ema_state_dict"])
|
| 56 |
+
model.eval()
|
| 57 |
+
|
| 58 |
+
y = torch.full((16,), 24, device="cuda", dtype=torch.long) # sprite/dcss-mon
|
| 59 |
+
with torch.autocast("cuda", dtype=torch.bfloat16):
|
| 60 |
+
imgs = sample(model, 16, 64, steps=50, y=y, guidance=3.0,
|
| 61 |
+
num_classes=cfg["num_classes"], device="cuda")
|
| 62 |
+
save_image_grid(imgs.float(), "monsters.png", nrow=4)
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
## Classes (conditional model)
|
| 66 |
+
|
| 67 |
+
Class ids are the alphabetical index into:
|
| 68 |
+
|
| 69 |
+
`emoji/activities, emoji/animals-nature, emoji/component, emoji/extras-openmoji,
|
| 70 |
+
emoji/extras-unicode, emoji/flags, emoji/food-drink, emoji/objects,
|
| 71 |
+
emoji/people-body, emoji/smileys-emotion, emoji/symbols, emoji/travel-places,
|
| 72 |
+
emoji/unknown, sprite/dawnlike, sprite/dcss-dungeon, sprite/dcss-effect,
|
| 73 |
+
sprite/dcss-item, sprite/dcss-misc, sprite/dcss-mon, sprite/dcss-player,
|
| 74 |
+
sprite/kenney-1bit, sprite/kenney-caves, sprite/kenney-characters,
|
| 75 |
+
sprite/kenney-micro-roguelike, sprite/kenney-modern-city,
|
| 76 |
+
sprite/kenney-pixel-platformer, sprite/kenney-pixel-shmup, sprite/kenney-rpg,
|
| 77 |
+
sprite/kenney-tiny-battle, sprite/kenney-tiny-dungeon, sprite/kenney-tiny-town`
|
| 78 |
+
|
| 79 |
+
## Training data and attribution
|
| 80 |
+
|
| 81 |
+
Images composited onto white backgrounds at 32/64px:
|
| 82 |
+
|
| 83 |
+
- [OpenMoji](https://openmoji.org) — CC-BY-SA 4.0 (the reason this model card
|
| 84 |
+
is CC-BY-SA)
|
| 85 |
+
- [Twemoji](https://github.com/jdecked/twemoji) — CC-BY 4.0, © Twitter/X and
|
| 86 |
+
contributors
|
| 87 |
+
- [Dungeon Crawl Stone Soup tiles](https://github.com/crawl/crawl) — public domain
|
| 88 |
+
- [Kenney asset packs](https://kenney.nl) — CC0
|
| 89 |
+
- [DawnLike tileset](https://opengameart.org/content/dawnlike-16x16-universal-rogue-like-tileset-v181)
|
| 90 |
+
— CC-BY 4.0, credit DragonDePlatino and DawnBringer
|
| 91 |
+
|
| 92 |
+
## Limitations
|
| 93 |
+
|
| 94 |
+
- The unconditional 32px emoji model partially memorizes its 8.5k-image
|
| 95 |
+
training set (~1/3 of samples are near-duplicates of training images).
|
| 96 |
+
- Rare classes (a few hundred images) produce less diverse samples.
|
| 97 |
+
- `sprite/kenney-characters` is trained on paper-doll layers (bodies,
|
| 98 |
+
clothing, hats as separate sprites), so it generates those parts rather
|
| 99 |
+
than assembled characters, and retains some flat-green artifacts from a
|
| 100 |
+
data-contamination issue fixed partway through training (see repo history).
|
| 101 |
+
- Outputs are white-background RGB; no alpha channel.
|
samples_grid.png
ADDED
|
|
Git LFS Details
|
sprite-gpt-cond64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:45ca5c1d11c0f6520e0367dbd718f60d35de78ff702d5b3b1378bfb86c55ac03
|
| 3 |
+
size 223277955
|
sprite-gpt-emoji32.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:09f0d2b99c1c3a6460ba51d49e9a851bbb1fe11cb7a9d6cd473f1a38f91d33a4
|
| 3 |
+
size 116330147
|