Instructions to use CheezOne/pixel-art-sprite-generator-16x16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use CheezOne/pixel-art-sprite-generator-16x16 with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-to-image', 'CheezOne/pixel-art-sprite-generator-16x16');
Pixel Sprite Generator 16×16 (runs in your browser)
Try it: CheezOne/pixel-art-sprite-generator-demo. No install, no GPU, no server.
A tiny 20M-parameter text-to-pixel-art model that makes native 16×16 sprites: real pixels from a fixed palette, not a downscaled diffusion image. Prompts work in English, 中文, 日本語 and 한국어.
Unfiltered samples, 8 per prompt (PyTorch, guidance 3). Rows: English prompts, then 红色药水瓶 / 金色钥匙 / 绿色史莱姆怪物 / 宝箱, then 赤いポーション / 金の鍵 (Japanese katakana and kana-heavy prompts are the weak spot), then 빨간 물약 / 황금 열쇠.
- The whole model is a 26 MB ONNX file, plus a 118 MB multilingual text encoder that the browser caches.
- MaskGIT-style parallel decoding: 12 forward passes make one batch of sprites. It uses WebGPU when available and falls back to WASM. In a headless Chromium on WASM (no GPU), int8, 4 sprites took 20 s. WebGPU is much faster.
- Output: palette-indexed 16×16 with transparency. Download it as a 16×16 PNG or an upscaled 256×256 PNG.
中文简介:一个只有约 20M 参数的小模型,在浏览器里把文字变成原生 16×16 像素精灵图(游戏道具、角色、怪物)。 支持中文、日文、韩文、英文输入,不需要显卡和服务器,提示词不会离开你的设备。
How it works
| part | details |
|---|---|
| text encoder | sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2, frozen; mean pooling and L2 norm. Browser: Xenova/... q8 |
| generator | bidirectional transformer, d=384, 8 layers, 6 heads, over 256 pixel tokens; vocabulary = 4097 palette colours (0 = transparent) |
| conditioning | text embedding → 4 prefix tokens; classifier-free guidance via a learned null vector |
| decoding | MaskGIT: start fully masked, predict all pixels, keep the most confident, re-mask the rest (cosine schedule) |
Files
| file | what |
|---|---|
onnx/model_quantized.onnx |
int8 generator, 26 MB, used by the demo. One step: tokens int64 [B,256] + cond float32 [B,384] → logits [B,256,4097] |
onnx/model.onnx |
fp32 generator, 82 MB |
palette.json |
RGB for each token id |
null.json |
unconditional vector for CFG |
config.json |
architecture plus default sampling settings (steps 12, cfg 3) |
model.safetensors |
PyTorch weights, for scripts/pix_train.py |
pix.js |
browser reference implementation of the decoding loop |
ONNX parity with PyTorch (same inputs): fp32 argmax agreement 100.0%, int8 92.3%.
Use it in your own web page / game tool
Copy pix.js from this repo; it loads the ONNX model and the encoder from the Hub:
import { load, encode, generate, pngURL } from "./pix.js";
await load();
const sprites = await generate(await encode("红色药水瓶"), { n: 4, seed: 7 });
document.querySelector("img").src = pngURL(sprites[0], 16); // 256×256 PNG
Python
huggingface-cli download CheezOne/pixel-art-sprite-generator-16x16 --local-dir pix16
python pix16/scripts/pix_train.py sample pix16 out.png --encoder sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 --prompts "golden key" "宝箱" --n 8
Training
- Data: Angais/pixel-art-atlas-1.4m. It has 1,409,404 native 16×16 sprites on a 4097-colour palette across 6,194 subjects, released under CC0.
- Objective: masked-token cross-entropy with a cosine masking ratio. 10% of samples were trained without conditioning, for CFG.
- Compute: 24,000 steps, batch 512, lr 6e-4 cosine, bf16, on one NVIDIA L40 (2.5 h). Final val loss 2.01.
- Reproduce:
jobs/pixel/job.shruns everything: download, embed, train, sample.
Licence (please read)
The training sprites were generated with Krea 2 and dedicated to the public domain (CC0) by the dataset author. The Krea 2 Community License counts models "distilled" from Krea 2 outputs as derivatives. To be safe, we release this model under the same Krea 2 Community License terms:
- Free for research and personal use.
- Free for commercial use by individuals and organisations with under US$1M annual revenue, which covers most indie game developers.
- Above that, contact Krea.
See LICENSE. Sprites you generate are yours to use under the same terms. We plan a v1 trained only on data from Apache-2.0 models.
Limitations
- 16×16 only, single object or character, front or 3/4 view. No animation frames yet.
- Rare or compound prompts ("a cat riding a dragon") fall back to the nearest common subject.
- Non-English prompts go through a multilingual sentence encoder that was never trained on these captions. Chinese works well. Japanese works for kanji words (剣, 宝箱, 魔法の杖, ドラゴン) but often fails for katakana loanwords (ポーション, スライム). Some Korean words miss (해골 → not a skull). If a prompt misses, try the English word.
- No safety filtering. The training data is game-asset subjects only.
More from CheezOne
Small open models for Chinese / Japanese / Korean / English apps. All of them run on CPU, and most in the browser.
- pii-detector-chinese-japanese-korean-english: PII detector (zh/ja/ko/en): find and redact names, phones, IDs, addresses. ONNX, runs on CPU and in the browser
- prompt-injection-jailbreak-detector-chinese-japanese-korean-english: Prompt-injection / jailbreak detector (zh/ja/ko/en): a guardrail for LLM apps
- reranker-chinese-japanese-korean-multilingual-small: Small CJK reranker (140M) for RAG: beats other small rerankers on MIRACL zh/ja/ko
- Downloads last month
- -