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, v2 preview (runs in your browser)
Try it: CheezOne/pixel-art-sprite-generator-demo. No install, no server; prompts never leave your device.
A 36.33M-parameter text-to-pixel-art model that makes native 16×16 sprites: real pixels from a fixed palette, with transparency, not a downscaled diffusion image. Prompts can be English, 中文, 日本語 or 한국어, and short prompts ("cat", "宝箱", "카메라") work.
Preview quality: please read. Simple objects (potions, cups, apples, hearts, trees, swords, cats) come out close to the training data. Objects with fine detail (cameras, gears, music-note icons, robots) are still clearly worse than the real sprites, and one prompt gives fairly similar variations. See the side-by-side below: real training sprites on the left, our samples from a short prompt on the right.
中文简介:在浏览器里把文字变成原生 16×16 像素图标(道具、角色、动物、食物、图标),支持中日韩英短词输入。预览版:简单物体效果接近训练数据, 相机、齿轮、音符这类细节多的图标仍明显不如真图。上图左边是训练数据真图,右边是只输入短词生成的结果。
What changed in v2
v1 had two problems: it squeezed the prompt into one sentence vector, and it was trained only on long English captions. As a result, short prompts and non-English prompts came out poorly. v2 fixes this:
Token-level text conditioning: the generator attends to every token of the prompt (as prefix tokens), not one pooled vector.
Prompt mix during training:
- full English caption 35%
- English subject word only ("camera") 20%
- zh/ja/ko translation of the caption ~20%
- zh/ja/ko translation of the subject the rest
- unconditional 10%, for classifier-free guidance
Translations: 6,142 subjects and 161k captions, made with Qwen2.5-7B-Instruct and filtered by script/language checks.
Smaller browser download: the text encoder is CheezOne/paraphrase-multilingual-MiniLM-L12-v2-zh-ja-ko-en, 47 MB int8 instead of 118 MB.
Speed and size
| part | size |
|---|---|
generator onnx/model_quantized.onnx (int8) |
37 MB |
| text encoder (int8, cached after first visit) | 47 MB |
Measured in headless Chromium on a 4-vCPU machine without a GPU (WASM, 4 threads, 16 steps): about 8 s per sprite. The demo shows each sprite as soon as it is done. With WebGPU the whole batch of 4 is generated at once and is much faster. The demo page enables multi-threaded WASM through cross-origin isolation headers.
How it works
| part | details |
|---|---|
| text encoder | frozen multilingual MiniLM (384-d); its token states (≤32 tokens) are fed to the generator |
| generator | bidirectional transformer, d=512, 10 layers, 8 heads, over the 256 pixel tokens plus the prompt tokens; 4097-colour palette (0 = transparent) |
| decoding | MaskGIT: start fully masked, predict all pixels, keep the most confident, re-mask the rest (cosine schedule, 16 steps); classifier-free guidance 3 |
ONNX parity with PyTorch on the same inputs: fp32 argmax agreement 100%, int8 94.1%. We checked int8 visually in the browser: the output looks the same as PyTorch's.
Files
| file | what |
|---|---|
onnx/model_quantized.onnx |
int8 generator used by the demo. Inputs: tokens int64 [B,256], text float32 [B,L,384], text_mask float32 [B,L]. Output: logits [B,256,4097] |
onnx/model.onnx |
fp32 generator (145 MB) |
model.safetensors, config.json, palette.npy |
PyTorch weights for scripts/pix2_train.py |
palette.json, null.json |
palette RGB; unconditional prompt token for CFG |
pix.js |
browser reference implementation (encoder + decoding loop) |
Use it in your own page / tool
import { load, encode, generate, pngURL } from "./pix.js"; // copy pix.js from this repo
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/pix2_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: 1,409,404 native 16×16 sprites, 6,194 subjects, released under CC0.
- Run: 18,833 steps, batch 512, lr 5e-4 cosine, bf16, on one NVIDIA L40. That is 0.6372 s/step and 3.4 h. Final validation loss: 1.9798 with full captions, 2.0799 with subject-only prompts.
- Reproduce:
jobs/pixel2/job.sh(download → train → real-vs-generated grids) plusscripts/pix2_export.py.
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.
- Above that, contact Krea.
See LICENSE.
Limitations
- Preview quality (see above). 16×16 only; a single object or character; no animation frames.
- Some subject translations are wrong (e.g. "slime" → 浆糊), so a few CJK prompts can miss. If that happens, try the English word.
- Low variety for a given prompt at the default guidance. Lower Guidance or raise Variety in the demo for more varied results.
- No safety filtering. The training data covers game-asset and everyday-object subjects only.
More from CheezOne
- paraphrase-multilingual-MiniLM-L12-v2-zh-ja-ko-en: the 47 MB en/zh/ja/ko text encoder used here
- reranker-cjk-small: small CJK reranker for RAG
- prompt-injection-guard-cjk-small: LLM guardrail
- pii-detector-cjk-small: PII detection and redaction
- Downloads last month
- -