|
Download README.md from FrameXlabs/Trout: direct link, hf CLI and curl.
- Browser
- Download file 5.21 kB
-
https://huggingface.co/FrameXlabs/Trout/resolve/main/README.md
- Command line
-
hf download hf://FrameXlabs/Trout/README.md
-
curl -L -o README.md https://huggingface.co/FrameXlabs/Trout/resolve/main/README.md
5.21 kB
| license: cc-by-nc-4.0 | |
| pipeline_tag: text-to-image | |
| library_name: pytorch | |
| datasets: | |
| - Angais/pixel-art-atlas-1.4m | |
| tags: | |
| - pixel-art | |
| - text-to-image | |
| - masked-diffusion | |
| - discrete-diffusion | |
| - diffusion-llm | |
| - from-scratch | |
| # Trout: a from-scratch diffusion language model for 16×16 pixel art | |
| **Author:** FrameXlabs | |
| **Live demo:** [Trout Pixel Studio](https://huggingface.co/spaces/FrameXlabs/Trout) | |
| **License:** [CC BY-NC 4.0](LICENSE) — free for education, research and personal non-commercial use with credit. | |
| **Named after:** the trout, a small fish — small, real, and trained from scratch. | |
| Trout is a from-scratch re-implementation of the same *kind* of model as | |
| [Tessera-small](https://huggingface.co/thejagstudio/tessera-small) (TheJagStudio) with the | |
| **same parameter count (47.6M)**: a joint text+pixel bidirectional masked-diffusion transformer | |
| that treats a 16×16 sprite as a 256-token sentence over a learned 512-colour palette, conditioned | |
| on a frozen CLIP text encoder. Nothing was copied from the reference — the palette is rebuilt from | |
| the source data with our own frequency-weighted OKLab k-means, the weights are trained from random | |
| initialisation with our own code, and the sampler is our own implementation of the same decoding | |
| strategy (parallel confidence-ordered unmasking with CFG, Gumbel-annealed choice and spatial NMS). | |
| ## Model | |
| | | | | |
| |---|---| | |
| | Parameters | 47.6M (47,597,568) (Trout-small) — frozen CLIP text tower not included (MIT licensed) | | |
| | Architecture | joint text+pixel bidirectional transformer, hourglass 2 + 8 + 2 blocks (2×2 patch-merged core), width 512, 8 heads, QK-RMSNorm, 2D axial RoPE, Conv-SwiGLU, adaLN-single, 4 registers, self-conditioning | | |
| | Text encoder | frozen `openai/clip-vit-base-patch32` text tower, 24 tokens | | |
| | Vocabulary | 512 palette tokens (frequency-weighted OKLab k-means on the data, ΔE 0.010 mean quantisation error) + `<mask>` | | |
| | Objective | absorbing-state masked diffusion, cosine schedule, blob masks, perceptual (OKLab) label smoothing, CFG dropout, self-conditioning | | |
| | Sampler | parallel confidence-ordered unmasking with CFG, Gumbel-annealed choice, spatial NMS; inpainting supported | | |
| ## Training (honest numbers) | |
| Trout was trained **from scratch** on | |
| [Pixel Art Atlas 1.4M](https://huggingface.co/datasets/Angais/pixel-art-atlas-1.4m) (5 of 15 train | |
| shards, 16-sprite batches, 3000 optimizer steps ≈ 48,000 sprites seen) | |
| on a shared **CPU** sandbox — roughly 0.11% of the sprite-passes | |
| of the reference recipe (82,342 steps × 512 sprites on an RTX PRO 6000). The optimizer is AdamW (the reference used | |
| Muon+AdamW) with warmup + cosine decay, EMA 0.99. It is a real training run, but a | |
| very short one, so the model is intentionally undertrained: expect plausible palettes, silhouettes | |
| and colour blobs rather than crisp objects. Increase sampling steps / CFG scale for the best of | |
| what it has learned. | |
| | Metric (final checkpoint) | Value | | |
| |---|---| | |
| | Validation NLL | 2.108 nats / pixel (perplexity 8.23 of 512) | | |
| | Validation accuracy | 56.0% of masked pixels | | |
| | Palette quantisation | mean ΔE 0.010, p95 ΔE 0.025 | | |
| | Trainable parameters | 47,597,568 | | |
| (For scale: Tessera-small reports validation NLL 0.859 nats/pixel and 78.8% masked-pixel accuracy | |
| after its full 82,342-step run.) | |
| ## Usage (non-commercial) | |
| ```python | |
| from huggingface_hub import hf_hub_download | |
| from trout.pipeline import TroutPipeline # code in this repo's `trout/` folder | |
| ckpt = hf_hub_download("FrameXlabs/Trout", "trout-small-fp16.pt") | |
| pipe = TroutPipeline.from_checkpoint(ckpt, device="cpu") | |
| images = pipe(["red health potion bottle"], num_per_prompt=8, steps=16, cfg_scale=3.0, seed=0) | |
| pipe.grid(images).save("potions.png") | |
| ``` | |
| Or try it live (the model runs in the Space): **[Trout Pixel Studio](https://huggingface.co/spaces/FrameXlabs/Trout)**. | |
| ## Files | |
| | File | Contents | | |
| |---|---| | |
| | `trout-small-fp16.pt` | fp16 weights, model config, palette, text-encoder id, training step | | |
| | `model_config.json`, `train_config.json` | architecture and training hyper-parameters actually used | | |
| | `palette.json` | the 512-entry palette learned from the dataset | | |
| | `metrics.jsonl` | the full training + validation log | | |
| | `showcase.png` | sample grid (12 prompts × 4 samples) | | |
| | `trout/` | inference code (model, sampler, palette, pipeline, CLIP wrapper) | | |
| ## Credits | |
| - **[Angais](https://huggingface.co/Angais)** for creating and openly releasing | |
| [Pixel Art Atlas 1.4M](https://huggingface.co/datasets/Angais/pixel-art-atlas-1.4m) — Trout was trained on it. | |
| - **[Jagrat Patel (TheJagStudio)](https://huggingface.co/thejagstudio)** — Tessera-small inspired this | |
| from-scratch build and defines the model family Trout reimplements at the same size. | |
| - The frozen text encoder is OpenAI's CLIP ViT-B/32 text tower (MIT). | |
| ## License | |
| Trout is released under **[CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/)**. Free for | |
| education, research and personal non-commercial use with credit ("Trout by FrameXlabs"). | |
| Commercial use requires a separate license. Third-party parts keep their own licenses: the CLIP text | |
| encoder (OpenAI, MIT) and the Pixel Art Atlas 1.4M dataset (Angais). | |