--- title: PixelLock emoji: ๐ŸŽจ colorFrom: purple colorTo: indigo sdk: docker app_port: 7860 pinned: true license: gemma short_description: Footprint-locked AI pixel-art retexturing models: - solarkyle/pixellock-gemma-12b-pixelart-gguf tags: - gradio - build-small-hackathon - track:wood - sponsor:modal - achievement:offbrand - achievement:welltuned - achievement:llama - achievement:sharing - achievement:fieldnotes - achievement:offgrid - best-demo - bonus-quest-champion - pixel-art --- # ๐ŸŽจ PixelLock โ€” AI Pixel-Art Retexturing Upload a sprite, pick a vibe (or write your own), hit **Run**. PixelLock restyles the colors and shading while keeping the **exact silhouette** โ€” pixel-perfect, *guaranteed by construction*. > โš ๏ธ **This Space runs on CPU** (the hackathon org has no dedicated-GPU credits), so > live edits won't run *here*. **โ–ถ Try it live on GPU โ†’ > https://huggingface.co/spaces/solarkyle/pixellock** (cold-starts ~60s) โ€” or watch > the 45-second demo video linked below. ## ๐Ÿ”— Links - ๐ŸŽฅ **Demo video:** [WATCH โ–ถ](https://youtu.be/Ju-Mpddfn3c) - ๐Ÿ“ฃ **Social post:** [SEE POST](https://x.com/NeuronsAndBytes/status/2066577400834506843) - ๐Ÿง  **Model (fine-tuned GGUF):** https://huggingface.co/solarkyle/pixellock-gemma-12b-pixelart-gguf - ๐Ÿ“„ **Full technical writeup:** [read it](https://huggingface.co/solarkyle/pixellock-gemma-12b-pixelart-gguf/blob/main/TECHNICAL_WRITEUP.md) ## The idea: the *wrong* model on purpose PixelLock does **not** use an image generator. It uses a **fine-tuned text LLM** (Gemma-4-12B). The sprite is serialized to a tiny text wire โ€” a `PALETTE` block plus a `GRID` of space-separated cells โ€” and the model **rewrites that text** in a new style. The trick is a per-sprite **GBNF decoding grammar** (llama.cpp): every transparent cell is pinned to a fixed literal, so the model is *physically incapable* of moving a pixel. The footprint and transparency are preserved **by construction**, not by luck. It's language modeling, not diffusion โ€” and that's exactly why the shape can never break. In a benchmark, *no* model could emit a correct 32ร—32 grid unconstrained (~0/150 attempts); the grammar takes validity from **0% โ†’ 100%** at every size (16ร—16 โ†’ 128ร—128, incl. 2ร— upscale), footprint-perfect every time. ## The tech - **Fine-tuned model** โ€” QLoRA fine-tune of Gemma-4-12B (**trained on Modal**, A100-80GB) on a curated corpus of palette-indexed pixel-art sprites (โ‰ค64px); completion-only loss, step-checkpointing, final eval loss **0.378**. Exported to GGUF (q4_k_m). - **Grammar-constrained decoding** โ€” a per-sprite GBNF grammar compiled from the input footprint; the silhouette is locked in the decoder, not post-filtered. - **Custom Gradio UI** โ€” a heavily themed `gr.Blocks` interface (Off-Brand) that builds the grammar per upload, footprint-checks the output, and shows you the **raw text the model wrote**. - **Serving** โ€” Docker GPU Space running llama.cpp `llama-server` (CUDA) with the per-request grammar; auto-sleeps when idle. Built for the **Build Small** hackathon ยท *Thousand Token Wood* track.