|
Download README.md from trkmnu/pixel-dit: direct link, hf CLI and curl.
- Browser
- Download file 3.76 kB
-
https://huggingface.co/trkmnu/pixel-dit/resolve/main/README.md
- Command line
-
hf download hf://trkmnu/pixel-dit/README.md
-
curl -L -o README.md https://huggingface.co/trkmnu/pixel-dit/resolve/main/README.md
3.76 kB
| license: cc-by-4.0 | |
| library_name: pytorch | |
| pipeline_tag: text-to-image | |
| tags: | |
| - diffusion | |
| - diffusion-transformer | |
| - dit | |
| - flow-matching | |
| - rectified-flow | |
| - pixel-art | |
| - from-scratch | |
| datasets: | |
| - Chan-Y/pixelart-308k | |
| # Pixel DiT — a text-to-pixel-art diffusion transformer, trained from scratch | |
| A **58M-parameter Diffusion Transformer** that turns a sentence into a 64×64 pixel-art sprite. | |
| Every weight of the image generator was trained from scratch on a single GPU — no fine-tuning of an existing image model. | |
|  | |
| ## Quick start | |
| ```python | |
| # pip install torch transformers safetensors huggingface_hub | |
| from huggingface_hub import hf_hub_download | |
| import sys; sys.path.insert(0, hf_hub_download("trkmnu/pixel-dit", "model.py").rsplit("/", 1)[0]) | |
| from model import PixelArtGenerator | |
| gen = PixelArtGenerator("trkmnu/pixel-dit") # cuda / mps / cpu picked automatically | |
| images = gen("a red dragon breathing fire on dark background, pixel art", seed=0) | |
| images[0].save("dragon.png") | |
| ``` | |
| Prompts work best in the dataset's style: `"<subject> on <color> background, pixel art"`. | |
| `cfg` (default 4.0) controls prompt adherence; `seed` gives a different variation. | |
| ## How it works | |
| | | | | |
| |---|---| | |
| | Architecture | DiT, 12 blocks, width 512, 8 heads, patch 4 → 256 tokens per image | | |
| | Conditioning | adaLN-Zero on (timestep + text) | | |
| | Text encoder | frozen CLIP ViT-B/32 text tower, pooled 512-d embedding | | |
| | Objective | rectified flow / flow matching (velocity prediction), logit-normal timestep sampling | | |
| | Guidance | classifier-free guidance, 10% text dropout during training with a learned null embedding | | |
| | Sampler | Euler, 50 steps | | |
| | Resolution | 64×64 RGB (shown upscaled with nearest-neighbour) | | |
| ## Training | |
| | | | | |
| |---|---| | |
| | Data | [Chan-Y/pixelart-308k](https://huggingface.co/datasets/Chan-Y/pixelart-308k), 308,765 captioned images, downsampled 256→64 (box filter) | | |
| | Preprocessing | images + CLIP embeddings computed once and stored as shards, then the whole dataset (~4 GB) kept in GPU memory — no data loader, no CPU bottleneck | | |
| | Optimizer | AdamW, lr 3e-4, betas (0.9, 0.99), no weight decay, 1k-step linear warmup, grad clip 1.0 | | |
| | Batch / steps | 128 × 60,000 steps (≈25 epochs) | | |
| | Precision | bf16 autocast, TF32 matmuls | | |
| | EMA | decay 0.9999 (with warmup) — released weights are the EMA | | |
| | Hardware | 1× NVIDIA L4 (24 GB), ~8.5 hours | | |
| | Final training loss | ≈0.039 | | |
| Before the full run, the pipeline was sanity-checked by overfitting 8 images on a T4. | |
| ## Limitations | |
| - **Attribute binding is weak.** The prompt is squeezed into one pooled CLIP vector, so the main subject and colours land, but secondary details often don't ("a cat *wearing a crown*" → a cat). | |
| - **Rare subjects drift** toward similar common shapes (e.g. a rocket can come out as a star). | |
| - **64×64 only.** | |
| - Trained on a fully synthetic dataset, so it inherits that dataset's style and biases. | |
| Planned v2: per-token text conditioning with cross-attention, larger model, 128×128. | |
| ## Files | |
| - `model.safetensors` — EMA weights | |
| - `config.json` — model hyper-parameters | |
| - `model.py` — model definition + `PixelArtGenerator` | |
| - `samples.png` — the grid above (seed 0, cfg 4.0, 50 steps) | |
| ## Credits | |
| Dataset: Chan-Y, *PixelArt-308K* (CC BY 4.0). Per the dataset card, its captions were generated with Gemma models and its images with FLUX.2-klein-4B — check those models' terms for commercial use. | |
| ```bibtex | |
| @dataset{pixelart_308k_2, | |
| title = {PixelArt-308K}, | |
| author = {Chan-Y}, | |
| publisher = {Hugging Face}, | |
| year = {2026}, | |
| url = {https://huggingface.co/datasets/Chan-Y/pixelart-308k} | |
| } | |
| ``` | |
| Trained by **Uğur Türkmen** — [ugurturkmen.com](https://ugurturkmen.com) | |