Seed 0, temperature 0.7, top-k 32 and guidance 3.
Pixl is a small text-to-pixel-art model trained from scratch. It draws a 32×32 scene one pixel at a time from a caption such as “a wizard at the top left … on a dark dungeon floor”. Training uses one million generated scenes made from four sprites placed in the image's four quadrants.
GPU compute: Thanks to @harshitruwali for the GPU time used to train the published model.
The weights are at ocdbytes/pixl. Install the package directly from this repository:
pip install git+https://github.com/ocdbytes/PIXL
import torch from PIL import Image from pixl.model import encode_captions from pixl.preprocess import decode, load_palette from pixl.tokenizer import Tokenizer from pixl.train import load_pretrained model = load_pretrained() # pass bf16=True for the half-size weights torch.manual_seed(0) caption = ("a purple robed wizard at the top left, a closed treasure chest at the top right, " "a brown bat at the bottom left and a red potion at the bottom right on a dark dungeon floor") ids = encode_captions([caption], Tokenizer.load(), length=model.config.caption) pixels = model.generate(ids, temperature=0.7, top_k=32, guidance=3.0) image = decode(pixels.view(32, 32).numpy(), load_palette()) image.resize((256, 256), Image.Resampling.NEAREST).save("scene.png")
The model expects the same shape of caption it saw during training: four objects from one sprite pack, each assigned to a quadrant, followed by the ground. See the model card for its vocabulary and limits, or use notebooks/generate.ipynb to try prompts.
uv run python -m pixl.app
# open http://127.0.0.1:7860Pick a preset or build a scene from the model's known sprite packs. Randomize chooses a new scene; Rotate clockwise is useful for checking whether the model follows positions. Advanced controls expose the seed, guidance and temperature.
| Flag | Effect |
|---|---|
--bf16 |
Use the smaller half-precision weights |
--device auto |
Pick an available GPU, falling back to the CPU |
--share |
Create a temporary public Gradio link |
If you installed with pip, install gradio separately.
- Model and inputs: palette, tokenizer and architecture
- Data: datasets and scene generation
- Training: running, evaluating and resuming training
- Remote training: Docker setup for an NVIDIA server
- Development: repository layout and checks
- Sprite sources: accepted sprite packs and licences
The code uses the BSD 3-Clause License. Downloaded images and datasets keep their original licences.

