Skip to content

πŸ’ƒ Free CC0 mannequin pose reference library for AI image tools (Nano Banana, ChatGPT, ComfyUI, Midjourney) β€” 250+ poses Γ— 5 angles in line art, names in ja/zh/en/ko

2.8 KB
Raw Blame
#!/usr/bin/env python3
"""Build the committed image tiers (w300, w600, w900) for every view that passed QC, and prune everything else.

Usage: python3 tools/build_images.py std=~/Downloads/pose-gallery-std73 sexy=... upper=...
Line art comes from <src>/img/<file>, photos from <src>/photo/<file>. A pose with a catalog `source` (a redrawn set,
tools/import_redraws.py) is read from the source set given under that name instead, e.g. digi=~/Downloads/....
A single view filled later (catalog `fills`, tools/import_fills.py) is read from its fill source, e.g. fill-r1=....
Clay, depth and normal maps (catalog `maps`) are read from maps=SRC/<kind>/<file>, e.g. maps=~/Downloads/pose-gallery-clay.
Only catalog views (non-null) and catalog
photos are built; any other file under images/ is deleted, so a view that fails QC leaves the repo.
Re-encoding is downscale-only from already-lossy sources: w900 q75 (lightbox/download),
w600 q72 (grid on 2x and 3x screens), w300 q70 (grid on 1x screens, thumbnails). The depth maps alone are lossless
at the source; q75 moves them by half a grey level on average on the body (checked on 60 views, 2026-10-31), far below
what a ControlNet preprocessor's own resize does.
"""
import json, pathlib, subprocess, sys

ROOT = pathlib.Path(__file__).resolve().parent.parent
TIERS = (("w900", 900, 75), ("w600", 600, 72), ("w300", 300, 70))


def main() -> None:
    srcs = {k: pathlib.Path(v).expanduser() for k, v in (a.split("=", 1) for a in sys.argv[1:])}
    want = set()
    for p in json.loads((ROOT / "data/catalog.json").read_text()):
        jobs = [("line", srcs[p.get("fills", {}).get(v) or p.get("source") or p["series"]] / "img" / f)
                for v, f in p["views"].items() if f]
        # Photo renders were made from the original drawings, so they always come from the series source.
        jobs += [("photo", srcs[p["series"]] / "photo" / f) for f in (p.get("photos") or {}).values()]
        jobs += [(k, srcs["maps"] / k / f) for f in (p.get("maps") or {}).values() for k in ("clay", "depth", "normal")]
        for kind, src in jobs:
            for tier, width, q in TIERS:
                dst = ROOT / "images" / kind / tier / src.name
                want.add(dst)
                if dst.exists() and dst.stat().st_mtime >= src.stat().st_mtime:
                    continue
                dst.parent.mkdir(parents=True, exist_ok=True)
                subprocess.run(["cwebp", "-quiet", "-mt", "-m", "6", "-q", str(q), "-resize", str(width), "0",
                                "-metadata", "none", str(src), "-o", str(dst)], check=True)
    pruned = 0
    for f in (ROOT / "images").glob("*/*/*.webp"):
        if f not in want:
            f.unlink()
            pruned += 1
    print(f"{len(want)} files in images/, pruned {pruned}")


if __name__ == "__main__":
    main()