pixelsprite AnimGPT v3: animate a 16 / 24 / 32 px sprite

Built with Qwen. The training data (pixelsprite-dataset-v3) contains outputs of Qwen-Image, which is under the Qwen Research License (non-commercial). The weights are therefore for non-commercial use only. See Licence and credits. This is not legal advice and carries no guarantee.

A small autoregressive transformer (39.2M parameters) that takes one pixel-art character sprite and draws it turned to another direction and performing an action (walk, run, punch, fly, ...), frame by frame. It is the pair of the text-to-sprite model pixelsprite-canvas-v3 and the successor of pixelsprite-animgpt.

example output

example strip

The strip: the input sprite, the sprite turned to the chosen direction, then the frames of the action. Made by example.py from this repo with seed 0; the character is not in the training set.

What is new in v3

AnimGPT (first release) AnimGPT v3
Training data 20,744 characters, outlined sprites only the same characters rendered with and without outline, plus 9,951 objects (views only)
Outline not a condition a condition: the model is told whether the sprite has a dark outline and keeps it
Validation characters 463 1,284

The architecture, the palette and the ONNX layout did not change, so code written for the first release needs one more input (ol) and nothing else.

What it does

Input a character sprite (16, 24 or 32 px), its kind (human / quadruped / bird), an action, a direction
Output, "view" the same character turned to one of 8 directions (45 degree steps)
Output, "animation" frame k of an action at a direction, given frame k-1 (frame 0 follows the view)
Actions 17 for humans, 3 for quadrupeds (idle, walk, run), 2 for birds (fly, glide); the list and the frame counts are in config.json
Sizes 16, 24 and 32 px, all trained

Directions: 0 = front, 90 = profile facing left, 180 = back, 270 = profile facing right.

samples

Columns: 1 = input sprite; 2-4 = the sprite turned to 90 / 180 / 270 degrees; 5-8 = walk frames 0-3 at 90 degrees. Rows come in pairs: ground truth from the 3D pipeline (white), then the model (grey). Held-out characters, 32 px, temperature 0.8, the released checkpoint.

How it works

  • Transformer: decoder-only, 12 layers, width 512, 8 heads, MLP 2048, pre-norm (39,179,265 parameters).
  • Per-pixel drawing: the target frame is written left to right, top to bottom. Each pixel is one of 1,024 palette colours or "transparent" (code/palette.npy, the palette of canvas-v3).
  • Sequence: [prefix: null text, size, S unknown-mask rows] [condition token] [reference S*S] [previous frame S*S] [target S*S] (S is the canvas size).
  • Condition token: the sum of embeddings for kind, action, azimuth, elevation, frame index, frame count, reference type (0 = the sprite itself, 1 = a pixelated front render of a 3D model) and outline (0 = none, 1 = outlined).
  • Two tasks: view (previous = reference; the character turned to an azimuth) and animation (previous = the last frame, or the view at that azimuth for frame 0).
  • Palette restriction: when sampling, only the reference sprite's own colours and "transparent" are allowed. This keeps the palette of the character.
  • Sampling: temperature 0.8.

Quick start

pip install torch safetensors pillow numpy huggingface_hub
hf download ihor-umanets/pixelsprite-animgpt-v3 --local-dir animgpt-v3
cd animgpt-v3
python example.py examples/cat32.png --kind quadruped --action walk --az 90 --out walk.gif

example.py is the whole recipe: it maps a sprite to the palette, detects the outline, draws the view at the chosen direction, then the frames of the action, each from the previous one, and saves a GIF and a PNG strip. It uses a GPU when there is one; --size 16 gives a quick look on a CPU.

The core of it:

import sys, json, numpy as np, torch
from safetensors.torch import load_file
sys.path.insert(0, "code")
from anim_model3 import AnimGPT3, ACTIONS, KINDS, AZIMUTHS
from pixelsprite_model import CanvasConfig

cfg = json.load(open("config.json"))
model = AnimGPT3(CanvasConfig.from_dict(cfg["model"])).eval()
model.load_state_dict(load_file("model.safetensors"))

# ref: (1, 32*32) long tensor of palette indices of your sprite, 1024 = transparent
t = lambda v: torch.tensor([v])
cond = dict(kind=t(KINDS.index("human")), action=t(ACTIONS.index("view")), az=t(AZIMUTHS.index(270)),
            el=t(0), frame=t(0), nfr=t(1), refk=t(0), ol=t(1))                      # ol: 1 = the sprite has a dark outline
allowed = torch.zeros(1, 1025, dtype=torch.bool); allowed[0, ref[0].unique()] = True; allowed[0, 1024] = True
view = model.sample(32, cond, ref, ref, temperature=0.8, allowed=allowed)          # the turned sprite
cond.update(action=t(ACTIONS.index("walk")), nfr=t(8))
frame0 = model.sample(32, cond, ref, view, temperature=0.8, allowed=allowed)       # walk frame 0

Files

File What
model.safetensors, config.json weights (float32, the released checkpoint) and the architecture, actions, frame counts, outline rule
best.pt the same checkpoint as a PyTorch file (model, meta); no optimizer state
code/ anim_model3.py (the model), anim_model.py, pixelsprite_model.py, palette.npy (1,024 x 3 sRGB)
example.py, examples/ a tested example, a 32 px input sprite and its output
onnx/ export for ONNX Runtime: prefill.onnx (whole context in one call, growing cache), step.onnx (one pixel per call, fixed cache, GPU), step_grow.onnx (growing cache, CPU), anim.data (shared float32 weights), embeddings.bin / .json (input tables, actions, palette, layout), parity.json (ONNX against PyTorch: max logit difference below 1e-4, argmax identical on all pixels)
train_log.json, samples/ training log, evaluation curves, a sample sheet
LICENSE_QWEN.txt, NOTICE.txt Qwen Research License and the notice for the data

Training

  • Data: pixelsprite-dataset-v3, blocks C and D. Block C: 20,744 characters (humans, quadrupeds, birds) turned into 3D, rigged, animated and pixelated back: 12 static views and the animations at 16, 24 and 32 px, every frame with and without outline from the same render. Block D: 9,951 objects, static views only. Splits are by character; 1,284 validation characters and objects give the numbers below.
  • Reference: the source sprite 60% of the time when one exists at that size, otherwise a pixelated front render. Views are weighted x8 and animals x2.
  • Optimisation: AdamW (weight decay 0.05), learning rate 3e-4, 1,000 warm-up steps, cosine decay, bf16 autocast, dropout 0.05. About 98k tokens per batch, one canvas size per step (16 / 24 / 32 with probabilities 0.25 / 0.25 / 0.5). Loss on the target pixels only. Warm-started from an earlier checkpoint of the same architecture.
  • Compute: 630 minutes on one NVIDIA RTX PRO 6000, 150,436 steps. The released weights are the last evaluation that was confirmed better than the noise of the measurement (step 121,788, minute 510, score 0.4642; the last step scores 0.4638).
  • Selection score: 0.8 x mean animation bits per pixel + 0.2 x mean view bits per pixel on the validation set.

eval curve

The dashed line marks the released checkpoint.

Results

Teacher-forced bits on the validation set (released checkpoint; lower is better):

16 px 24 px 32 px
Animation frame, bits per pixel 0.483 0.399 0.362
- outlined frames 0.380 0.346 0.320
- frames without outline 0.592 0.452 0.402
View of a character, bits per pixel 0.818 0.522 0.528
View of an object, bits per pixel 0.830 0.619 0.644

These numbers are not comparable with the card of the first release: the validation set is different and half of it is frames without outline, which are harder to predict. Training bits per pixel at that step are 0.50 / 0.44 / 0.42.

Quality, honestly

  • Animation of a given view is good. Walk and fly cycles follow the 3D pipeline closely (sample sheet, columns 5-8).
  • Turning to a new direction is weaker. Silhouettes and colours drift: a wrong back view, an odd profile, lost accessories. A view has to invent hidden sides, while a frame mostly copies the previous one.
  • Errors propagate. Every action starts from its drawn view, so a bad view carries into all frames of that action. Draw again with another seed when it happens.
  • Objects: the model saw views of objects, but turning an object from a single sprite loses details (a skull without a face, a chest without a lock). Treat it as an experiment.
  • No human study: we measured bits per pixel and looked at samples.

Limitations and intended use

  • For: prototypes, game jams and research on autoregressive pixel models, non-commercially. Characters: people, four-legged animals and birds in the dataset's styles.
  • Not for: buildings, other body shapes (snakes, fish, many legs) or sprites far from the data (isometric, top-down).
  • The reference should look like the dataset: one character, facing the camera. Odd poses, tiny details and large accessories (a bow, a staff) are often lost when turning.
  • Sampling is random: results depend on the seed and on the device.
  • Style and bias come from the source sprites (two AI-generated pixel-art sets), Qwen-Image restyling and the 3D pipeline, with their errors.

Licence and credits

  • Weights: CC BY-NC 4.0 (non-commercial; attribution). The training data contains outputs of Qwen-Image (Qwen Research License, non-commercial). Commercial use of the weights or of their output needs your own legal review and, where Qwen's licence applies, a separate licence from Qwen. This card gives no legal guarantee.
  • Built with Qwen. Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026 Hangzhou Tongyi Laboratory Technology Co., Ltd. All Rights Reserved. The text is in LICENSE_QWEN.txt; see NOTICE.txt for third-party material.
  • Source sprites: pixel-art-atlas-1.4m and pixelart-172k.

Links

Citation

@misc{umanets2026animgptv3,
  author       = {Umanets, Ihor},
  title        = {pixelsprite AnimGPT v3: turning and animating pixel-art character sprites with an autoregressive transformer},
  year         = {2026},
  howpublished = {\url{https://huggingface.co/ihor-umanets/pixelsprite-animgpt-v3}},
  note         = {Built with Qwen. Non-commercial (CC BY-NC 4.0).}
}
Downloads last month
53
Safetensors
Model size
39.2M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Dataset used to train ihor-umanets/pixelsprite-animgpt-v3