Spaces:
Sleeping
Sleeping
File size: 2,108 Bytes
9193eb5 22938ed 9193eb5 22938ed 9193eb5 22938ed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | ---
title: AutoSprite
emoji: 👾
colorFrom: indigo
colorTo: pink
sdk: gradio
sdk_version: 6.32.0
app_file: app.py
pinned: false
license: mit
short_description: Few pixel-art frames in, full spritesheet out (CPU)
---
# AutoSprite
Upload as few as one consistent pixel-art frame (16x16 or 18x18 work best, up to 24x24) and
AutoSprite fills in the rest of a platformer set — `idle`, `walk_1..3`, `jump` — then packs a
downloadable spritesheet, atlas JSON, per-frame PNGs and a walk-cycle GIF.
## How it works
- **Model:** a 3.5M-parameter U-Net (`autosprite/model.py`) that sees whichever poses you gave
and predicts the missing ones. Its output head is a *palette pointer*: each pixel picks one of
the colors already in your frames (or transparency), so results stay crisp and on-palette.
- **Data:** no scraped sprites. `autosprite/synth.py` procedurally generates unlimited side-view
characters (random proportions, palettes, hair, hats, shading, outlines, walk styles) rendered
consistently in all five poses. Training hides random poses and learns to reconstruct them.
- **Runtime:** exported to ONNX and run with `onnxruntime` on CPU — about a hundred
milliseconds per sheet, no GPU required.
- **Input cleanup:** upscaled art (e.g. 320x320 of an 18x18 sprite) is detected and resampled
back to its native grid with nearest-neighbor, flat backgrounds are removed, and near-duplicate
shades are merged.
## Run locally
```bash
pip install -r requirements.txt gradio
python app.py
```
## Train your own
```bash
pip install torch onnx
python train.py --steps 16000 --out weights/autosprite.pt
python export_onnx.py weights/autosprite.pt weights/autosprite.onnx
python evaluate.py examples/alan --out eval_alan.png
```
Training uses Apple `mps`, CUDA, or CPU automatically.
## Limits
- One side-view platformer pose set; sprites larger than 24x24 (e.g. big Mario at 16x32) are not
supported yet.
- The model has only ever seen procedural characters, so very stylized art (3/4 views,
big silhouette changes between frames) gets approximate frames that are worth touching up.
|