Pixellab based system

This commit is contained in:
=
2026-10-01 22:46:04 -05:00
parent 97a27f9a42
commit 0e905a2824
650 changed files with 10879 additions and 113 deletions

View File

@@ -1,6 +1,13 @@
# sprite_gen
Procedural 96x96 creature sprites for businesses. You give it a business name and logo. It picks a type, builds a creature from parts and recolors it with the logo's brand colors.
Procedural creature sprites for businesses. You give it a business name and logo. It picks a type, builds a creature from parts and recolors it with the logo's brand colors.
There are two part libraries:
| Library | Size | Art | Registry |
|---|---|---|---|
| `pixellab` (default) | 64x64 | Generated with [PixelLab](https://pixellab.ai), see [PixelLab library](#pixellab-library) | `sprite_parts_pl.py` + `pixellab_library/*.json` |
| `classic` | 96x96 | Hand-written text grids | `sprite_parts.py` |
## Setup
@@ -27,9 +34,12 @@ python generate_sprite.py "Rosas Landscaping" --type grass --colors "#2E7D32,#FB
# A different creature for the same business
python generate_sprite.py "Rosas Landscaping" logos/rosas.png --type grass --reroll 1
# Both libraries side by side
python generate_sprite.py "Rosas Landscaping" logos/rosas.png --type grass --compare
```
Each run writes `sprites/<slug>.png` (96x96), `sprites/<slug>@4x.png` and `sprites/<slug>.json` (type, parts, colors). With `--reroll N`, the file names end in `-rN`.
Each run writes `sprites/<slug>.png`, `sprites/<slug>@4x.png` and `sprites/<slug>.json` (library, type, parts, colors). With `--reroll N`, the file names end in `-rN`. With `--compare`, each library writes `<slug>-<library>.*` and `<slug>-compare.png` shows them next to each other at the same height. Both use the same type and colors.
| Option | Meaning |
|---|---|
@@ -37,6 +47,8 @@ Each run writes `sprites/<slug>.png` (96x96), `sprites/<slug>@4x.png` and `sprit
| `--desc TEXT` | Description sent to the classifier (default: the name) |
| `--colors "#main,#accent"` | Manual colors; overrides the logo |
| `--reroll N` | Alternate creature; the name alone always gives the same sprite |
| `--library NAME` | `pixellab` (default) or `classic` |
| `--compare` | Render with both libraries and write a comparison sheet |
| `--out DIR` | Output folder (default `sprites`) |
| `--scale N` | Size of the upscaled copy (default 4, `1` disables it) |
@@ -50,17 +62,40 @@ Use a CSV with the columns `name,logo,type,description`. Only `name` is required
OPENROUTER_API_KEY=<API_KEY> python generate_sprite.py --batch businesses.csv --out sprites
```
## Editing the art
Add `--compare` to get both libraries for every row.
The parts are text grids in `parts_src/<slot>/<name>.txt`, compiled to `parts/<slot>/<name>.png`. Weights, compatibility and deny lists live in `sprite_parts.py`. See `AI_PIXEL_ART_GUIDE.md` for the palette and anchor rules.
## PixelLab library
Each base creature has a spec in `pixellab_library/<body>.json`: the prompt and seed for its base image, plus one edit prompt per part ("add a pair of gold horns ..."). `pixellab_library.py` generates the base with PixelLab's pixen model and makes each part as an edit of that exact image. The part is the pixel difference between the edit and the base, so it lines up with the base and gets its attach point automatically. The full spec schema and conventions are in the docstring at the top of `pixellab_library.py`.
Art is drawn in a stand-in palette (teal body, crimson details, gold elemental bits) that maps to the recolorable palette keys. Elemental features can use a fixed-color ramp instead (`fire`, `bluefire`, `ice`, `electric`, `ghostfire`): they keep their own colors whatever the brand, and they only appear on their types. When the generator picks parts, it skips any part that would push the sprite past 64x64, so every part can be offered to every body.
Needs `PIXELLAB_API_KEY` in the environment or in `.env`.
```bash
python build_parts.py # compile all grids (or pass part names)
python validate_parts.py --sample 3000 # check colors, anchors, canvas fit on random composites
python preview.py bases # contact sheets in preview/
python preview.py part back plant_bulb # one part on every base it fits
python preview.py zoom body=base_fox tail=tail_leaf
python generate_sprite.py --sprite-list SPRITES.md # regenerate the part list and weight report
python pixellab_library.py generate pl_fox --base-only # base image only: review it first
python pixellab_library.py generate pl_fox # every missing edit (raw images in pixellab_src/pl_fox/)
python pixellab_library.py extract pl_fox # grids in parts_pl_src/, PNGs in parts_pl/, diffs in preview/pixellab/diff/
python pixellab_library.py preview pl_fox # the body with each of its parts
python pixellab_library.py preview --cross # every part on every body, one sheet per slot
python pixellab_library.py preview --random 60 # real random picks
python pixellab_library.py cost # spend so far (pixellab_src/ledger.jsonl) and balance
python validate_parts.py --library pixellab --sample 3000
```
To change a part, edit its spec (new `seed` or wording), then run `generate <body> --parts <part> --force` and `extract <body>`. Regenerating a base deletes that body's old edits.
## Classic library
The parts are text grids in `parts_src/<slot>/<name>.txt`, compiled to `parts/<slot>/<name>.png`. Weights, compatibility and deny lists live in `sprite_parts.py`. See `AI_PIXEL_ART_GUIDE.md` for the palette and anchor rules. The PixelLab library's grids in `parts_pl_src/` use the same format, plus the fixed-ramp characters listed in `build_parts.py`.
```bash
python build_parts.py # compile all grids (or pass part names)
python validate_parts.py --library classic --sample 3000 # check colors, anchors, canvas fit on random composites
python preview.py --library classic bases # contact sheets in preview/
python preview.py --library classic part back plant_bulb # one part on every base it fits
python preview.py --library classic zoom body=base_fox tail=tail_leaf
python generate_sprite.py --library classic --sprite-list SPRITES.md # regenerate the part list and weight report
```
Do not run `--make-placeholders --overwrite`, because it replaces the real art with test placeholders.