
smalt-medium · tiny text-to-pixel-art
Made for nemini.ai & pixilab.ai.
The logo above, every letter and the slime, was drawn by its little sibling smalt-small.
smalt-medium draws 16×16 game sprites from a short prompt: potions, chests, swords, crowns, keys, monsters,
knights. Type red health potion, get a clean, transparent, palette-exact sprite you can drop straight into a game.
It is the bigger sibling of smalt-small: sharper shading, cleaner outlines and much better objects and creatures.
| Parameters | 49.3M |
| Output | 16×16 RGBA, every pixel one colour of a fixed 512-colour palette (index 0 = transparent) |
| Speed | ~0.17 s for 4 sprites on a GPU · ~1.8 s for one sprite on 2 CPU threads |
| Dependencies | torch, tokenizers, safetensors, numpy, pillow (no CLIP, no VAE) |
| License | MIT (weights and code) |
Smaller and faster: smalt-small (24.5M), which you can also try in the browser in smalt studio.
How it works
Every pixel is a token from a 512-colour palette. The model starts from a fully masked 16×16 canvas and fills it in in parallel, in about 16 steps: at each step it predicts a colour for every empty pixel and keeps the ones it is most sure about. The prompt is read by its own small text encoder, trained together with the image model. Because the output is palette indices, sprites come out pixel-perfect: hard edges, no blur, no stray anti-aliasing, true transparency.
The same loop does inpainting: lock some pixels, and the model fills the rest around them.
Quickstart
pip install torch tokenizers safetensors numpy pillow huggingface_hub
import sys
from huggingface_hub import snapshot_download
path = snapshot_download("PixilabAI/smalt-medium")
sys.path.insert(0, path) # the repo ships the small `smalt` package
from smalt import SmaltPipeline
pipe = SmaltPipeline(path) # cuda if available, else cpu
sprites = pipe("red health potion", n=4, seed=0) # 4 × 16×16 RGBA PIL images
for i, s in enumerate(sprites):
s.resize((128, 128), 0).save(f"potion_{i}.png") # 0 = nearest neighbour, keeps pixels crisp
Several prompts in one batch: pipe(["red key", "silver sword", "treasure chest"]).
Settings (keyword arguments):
| default | what it does | |
|---|---|---|
steps |
16 | decoding steps; 8 is faster, 24–32 a little cleaner |
guidance |
3.0 | how strictly the prompt is followed; 2–5 is the useful range |
temperature |
0.4 | lower = cleaner and more typical, higher = more variety (above ~1.0 adds stray pixels) |
seed |
random | same seed + same settings = same sprites |
Inpainting: pass a canvas of palette ids and a mask of the pixels to keep.
import numpy as np
tok = pipe.tokens("blue mana potion", n=1, seed=3) # (1, 256) palette ids
keep = np.zeros(256, bool); keep[128:] = True # keep the bottom half
new = pipe("red health potion", n=4, canvas=tok[0].cpu().numpy(), keep=keep)
Live steps: pipe.stream(prompt, n=4) yields the canvas after every step (step.tokens, step.preview,
step.confidence), handy for animations.
Prompting
Short prompts work best: the thing, plus a word or two about it. Two to six words.
- Objects:
red health potion,treasure chest,golden crown,iron shield,magic spellbook. - Creatures and characters:
frog with a crown,purple slime monster,knight in silver armor,purple bat,fox. - One extra word helps a lot when a prompt comes out wrong:
| plain | better |
|---|---|
gold coin (flat yellow disc) |
shiny gold coin |
orange fox (orange texture) |
cute orange fox, or just fox |
mushroom (comes out blue) |
red mushroom with white spots |
Limitations
- 16×16 only. It is a sprite model, not a scene or portrait model.
- Best at objects, creatures and characters. Tiles (
tile with …) tend to come out as flat colour fields, letters (text …) are unreliable, effects and interface pieces are rough. - A colour word plus one short noun can turn into a texture pattern (
orange fox); add a word (see the table above). - Silver and white metal can wash out to pale grey.
- English prompts only.
License
MIT, see LICENSE. Sprites you generate are yours to use, including commercially.
Inspiration: thejagstudio/tessera-small.
- Downloads last month
- 8

