π 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
Python ai-artai-image-generationart-referencecc0comfyuicontrolnetdatasetdrawing-referencefigure-drawingline-artmannequinmidjourneymultilingualnano-bananapose-referencereference-imagesstable-diffusion
feat(tools): import whole-set redraws from another source
wquguruc55d5c5c1293
diff --git a/tools/build_images.py b/tools/build_images.pyindex 5f625623..2054d570 100755--- a/tools/build_images.py+++ b/tools/build_images.py@@ -2,7 +2,9 @@"""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>. Only catalog views (non-null) and catalog+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/....+Only catalog views (non-null) and catalogphotos 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).@@ -17,7 +19,8 @@ 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["series"]] / "img" / f) for f in p["views"].values() if f]+ jobs = [("line", srcs[p.get("source") or p["series"]] / "img" / f) for f in p["views"].values() 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()]for kind, src in jobs:for tier, width, q in TIERS:diff --git a/tools/export_csv.py b/tools/export_csv.pyindex 3648d74e..62e38fec 100644--- a/tools/export_csv.py+++ b/tools/export_csv.py@@ -1,11 +1,12 @@#!/usr/bin/env python3-"""Write data/catalog.csv from data/catalog.json (o = view passed QC, x = failed QC, - = not generated)."""+"""Write data/catalog.csv from data/catalog.json (o = view passed QC, x = failed QC, - = not generated).+`source` is empty for the original generation and names the redraw source otherwise (tools/import_redraws.py)."""import csv, json, pathlibROOT = pathlib.Path(__file__).resolve().parent.parentVIEWS = ("front", "diag", "side", "above", "below")COLS = ("id", "orig_id", "series", "rating", "class_jp", "class_cn", "class_en", "class_kr",- "name_jp", "name_cn", "name_en", "name_kr")+ "name_jp", "name_cn", "name_en", "name_kr", "source")def main() -> None:diff --git a/tools/import_redraws.py b/tools/import_redraws.pynew file mode 100644index 00000000..89d48549--- /dev/null+++ b/tools/import_redraws.py@@ -0,0 +1,52 @@+#!/usr/bin/env python3+"""Stage whole-set redraws from another generator as a new source and point their catalog entries at it.++Usage: python3 tools/import_redraws.py SRC OUT --source digi+SRC is a redraw delivery with index.json (one row per set: set, shisei_id) and <group>/<set>/<view>.png.+Each listed view is written losslessly to OUT/img/<series>_<ID>_<view>.webp, the name the tiers use, so OUT works+as a source set for build_images.py, review_sheets.py, line_dups.py and pack_release.py (`--src digi=OUT`).+In data/catalog.json the pose gets `source` and its views are replaced as a whole set: a view the delivery lacks+becomes null, never a view kept from the old drawing (AGENTS Β§2, no mixing within a set). Names, class, rating and+orig_id stay; ja is the original naming and the delivery's own labels are not imported.+Run qc_merge.py afterwards: results from other sources no longer apply to these poses (docs/qc/README.md).+"""+import argparse, json, pathlib, subprocess++ROOT = pathlib.Path(__file__).resolve().parent.parent+VIEWS = ("front", "diag", "side", "above", "below")+++def main() -> None:+ ap = argparse.ArgumentParser()+ ap.add_argument("src")+ ap.add_argument("out")+ ap.add_argument("--source", required=True)+ a = ap.parse_args()+ src, out = pathlib.Path(a.src).expanduser(), pathlib.Path(a.out).expanduser()+ (out / "img").mkdir(parents=True, exist_ok=True)+ path = ROOT / "data/catalog.json"+ cat = json.loads(path.read_text())+ by_id = {p["id"]: p for p in cat}+ n = 0+ for row in json.loads((src / "index.json").read_text()):+ p = by_id[row["shisei_id"]]+ views = {}+ for v in VIEWS:+ png = next(src.glob(f"*/{row['set']}/{v}.png"), None)+ if png is None:+ views[v] = None+ continue+ name = f"{p['series']}_{p['id']}_{v}.webp"+ subprocess.run(["cwebp", "-quiet", "-lossless", "-metadata", "none", str(png), "-o", str(out / "img" / name)],+ check=True)+ views[v] = name+ n += 1+ p["source"] = a.source+ p["views"] = views+ p["gaps"] = {}+ path.write_text(json.dumps(cat, ensure_ascii=False, indent=1) + "\n")+ print(f"{a.source}: {n} views staged in {out / 'img'}")+++if __name__ == "__main__":+ main()diff --git a/tools/import_series.py b/tools/import_series.pyindex 263a79dd..559de7e7 100644--- a/tools/import_series.py+++ b/tools/import_series.py@@ -6,6 +6,7 @@ Entries of that series are replaced; others are kept. Views become bare file nam--general lists class_en values rated "general"; every other category of the series is "suggestive".Without --general the whole series is rated by --rating (default general).Per-pose decisions in data/rating_overrides.json (docs/qc/README.md, rating check) win over the category rule.+A pose redrawn from another source (tools/import_redraws.py) keeps its `source`, views and gaps."""import argparse, json, pathlib@@ -14,6 +15,7 @@ VIEWS = ("front", "diag", "side", "above", "below")FIELDS = ("id", "orig_id", "series", "added_in", "rating", "class_jp", "class_cn", "class_en", "class_kr","name_jp", "name_cn", "name_en", "name_kr", "desc_en", "views", "photos")OPTIONAL = ("bodies",) # duo: MF / FF figure pairing; kept only when the source has it+REDRAWN = ("source", "views", "gaps")def main() -> None:@@ -29,7 +31,9 @@ def main() -> None:overrides = json.loads(ov_path.read_text()) if ov_path.exists() else {}src = json.loads((pathlib.Path(a.src).expanduser() / "catalog.json").read_text())path = ROOT / "data/catalog.json"- cat = [p for p in json.loads(path.read_text()) if p.get("series") != a.series]+ old = json.loads(path.read_text())+ redrawn = {p["id"]: {k: p[k] for k in REDRAWN} for p in old if p.get("series") == a.series and p.get("source")}+ cat = [p for p in old if p.get("series") != a.series]for p in src:q = dict(p)q["series"] = a.series@@ -39,7 +43,7 @@ def main() -> None:q.setdefault("desc_en", "")q["views"] = {v: (pathlib.Path(p["views"][v]).name if p["views"].get(v) else None) for v in VIEWS}q.setdefault("photos", [])- cat.append({k: q.get(k) for k in FIELDS} | {k: q[k] for k in OPTIONAL if q.get(k)})+ cat.append({k: q.get(k) for k in FIELDS} | {k: q[k] for k in OPTIONAL if q.get(k)} | redrawn.get(p["id"], {}))path.write_text(json.dumps(cat, ensure_ascii=False, indent=1) + "\n")print(f"{a.series}: {len(src)} poses; catalog now {len(cat)}")diff --git a/tools/line_dups.py b/tools/line_dups.pyindex 7ad181be..d5d9c4bd 100644--- a/tools/line_dups.py+++ b/tools/line_dups.py@@ -2,6 +2,8 @@"""Flag views of one pose that are practically the same image (the edit model sometimes ignores the target angle).Usage: python3 tools/line_dups.py OUT.json std=SRC_IMG_DIR sexy=SRC_IMG_DIR upper=SRC_IMG_DIR+ python3 tools/line_dups.py data/qc-input/dups_digi.json --source digi digi=SRC_IMG_DIR+With --source only poses redrawn from that source are checked and the output is tagged with it (qc_merge.py).Lines are thickened with a min filter, then compared at 96x128; the same image scores < 6, distinct angles > 8.The non-front (later) view of each near-identical pair is flagged."""@@ -15,18 +17,22 @@ VIEWS = ("front", "diag", "side", "above", "below")def main() -> None:- out, srcs, flags = pathlib.Path(sys.argv[1]), dict(a.split("=", 1) for a in sys.argv[2:]), []+ args = sys.argv[2:]+ source = args[args.index("--source") + 1] if "--source" in args else None+ args = [x for x in args if "=" in x]+ out, srcs, flags = pathlib.Path(sys.argv[1]), dict(a.split("=", 1) for a in args), []for p in json.loads((ROOT / "data/catalog.json").read_text()):- if p["series"] not in srcs:+ key = p.get("source") or p["series"]+ if p.get("source") != source or key not in srcs:continue- d = pathlib.Path(srcs[p["series"]]).expanduser()+ d = pathlib.Path(srcs[key]).expanduser()im = {v: np.asarray(Image.open(d / p["views"][v]).convert("L").filter(ImageFilter.MinFilter(5)).resize((96, 128)), dtype=float)for v in VIEWS if p["views"].get(v)}for a, b in itertools.combinations(im, 2):diff = float(np.abs(im[a] - im[b]).mean())if diff < 6:flags.append({"set": p["id"], "angle": b, "kind": "structure", "reason": f"same image as {a} (diff {diff:.1f})"})- out.write_text(json.dumps(flags, ensure_ascii=False, indent=1))+ out.write_text(json.dumps({"source": source, "fails": flags} if source else flags, ensure_ascii=False, indent=1))print(f"duplicate panels {len(flags)}")diff --git a/tools/pack_release.py b/tools/pack_release.pyindex b6ded116..37914f7d 100644--- a/tools/pack_release.py+++ b/tools/pack_release.py@@ -5,7 +5,8 @@ Usage: python3 -I tools/pack_release.py 0.2.0 std=~/Downloads/pose-gallery-std73Writes to dist/:shisei-<series>-v<ver>.zip one per series, the w900 tier (line art + photos): the recommended downloadshisei-all-v<ver>.zip every series, w900- shisei-original-v<ver>.zip every series at the source resolution, from <src>/img and <src>/photo+ shisei-original-v<ver>.zip every series at the source resolution, from <src>/img and <src>/photo; redrawn sets+ (catalog `source`) from that source set, at its resolution (digi: 900x1200)Only files the catalog lists go in, so a view that failed QC never ships, even though the source sets still hold it.Every zip carries LICENSE-images (CC0, the images), LICENSE (Apache-2.0) and NOTICE, which credits the pose list. Theimages are already lossy WebP, so deflate barely shrinks them; it is used anyway because it costs nothing for the text.@@ -22,7 +23,8 @@ def entries(poses, original, srcs):for p in poses:for kind, key, sub in (("line", "views", "img"), ("photo", "photos", "photo")):for f in sorted(v for v in (p.get(key) or {}).values() if v):- disk = srcs[p["series"]] / sub / f if original else ROOT / "images" / kind / "w900" / f+ root = srcs[p.get("source") or p["series"]] if kind == "line" else srcs[p["series"]]+ disk = root / sub / f if original else ROOT / "images" / kind / "w900" / fout.append((disk, f"{kind}/{f}"))return out@@ -45,8 +47,9 @@ def main() -> None:ver = sys.argv[1]srcs = {k: pathlib.Path(v).expanduser() for k, v in (a.split("=", 1) for a in sys.argv[2:])}catalog = [p for p in json.loads((ROOT / "data/catalog.json").read_text()) if any(p["views"].values())]- if set(srcs) != {p["series"] for p in catalog}:- sys.exit(f"need a source dir for each series: {sorted({p['series'] for p in catalog})}")+ need = {p["series"] for p in catalog} | {p["source"] for p in catalog if p.get("source")}+ if set(srcs) != need:+ sys.exit(f"need a source dir for each series and redraw source: {sorted(need)}")dist = ROOT / "dist"dist.mkdir(exist_ok=True)diff --git a/tools/qc_merge.py b/tools/qc_merge.pyindex 546845fb..c4cc2564 100644--- a/tools/qc_merge.py+++ b/tools/qc_merge.py@@ -4,6 +4,9 @@Usage: python3 tools/qc_merge.py QC_DIR [--date YYYY-MM-DD]QC_DIR holds fail_*.json (panel review), name_*.json (pose-name check), optionally dups.json (tools/line_dups.py)and photo_*.json (photo-render review, docs/qc/photo_prompt.md). Without photo_*.json the previous photo results stay.+A result file with a top-level "source" applies only to poses whose catalog `source` matches; files without one apply+to poses without one. A redrawn set (tools/import_redraws.py) is therefore judged only on reviews of its new drawing,+while the old files stay so the old results remain reproducible (dups*.json from line_dups.py works the same way).Rules (docs/qc/README.md):- a set whose drawing does not show the named pose (match "no") fails every view as `structure`;- per-panel "pose mismatch" fails are dropped when the set-level check says yes/partial (the set check decides names);@@ -12,7 +15,7 @@ Rules (docs/qc/README.md):Catalog views keep their file only when the status is `pass`; other views become null and get a `gaps` entry.qc.json keeps every file name, so a later re-review can bring a view back."""-import argparse, datetime, glob, json, pathlib, re+import argparse, datetime, glob, json, pathlib, re, sysROOT = pathlib.Path(__file__).resolve().parent.parentVIEWS = ("front", "diag", "side", "above", "below")@@ -33,15 +36,28 @@ def main() -> None:cat = json.loads(cat_path.read_text())old = json.loads(qc_path.read_text()) if qc_path.exists() else {"views": {}}- sets = {}- for f in sorted(d.glob("name_*.json")):- for s in json.loads(f.read_text())["sets"]:- sets[s["set"]] = s- fails = []- for f in sorted(d.glob("fail_*.json")):- fails += json.loads(f.read_text())["fails"]- if (d / "dups.json").exists():- fails += json.loads((d / "dups.json").read_text())+ def load(pattern, key):+ """Entries of every matching file, each tagged with the file's source (None = the original generation)."""+ out = []+ for f in sorted(d.glob(pattern)):+ doc = json.loads(f.read_text())+ doc = {"fails": doc} if isinstance(doc, list) else doc+ out += [(doc.get("source"), x) for x in doc.get(key, [])]+ return out++ src = {p["id"]: p.get("source") for p in cat}+ # A redrawn set has no older results to fall back on, so an unreviewed view would pass silently: every view of+ # it must be on a panel sheet its source's reviewers listed, and the set must have a name check.+ seen = {(source, n.split("__")[0], v) for source, n in load("fail_*.json", "reviewed") if source and "__" in n+ for v in n.split("__")[1].removesuffix(".jpg").split("-")}+ named = {(source, n) for source, n in load("name_*.json", "reviewed") if source}+ todo = [f"{p['id']} {v}" for p in cat if p.get("source") for v in VIEWS+ if p["views"].get(v) and (p["source"], p["id"], v) not in seen] + \+ [f"{p['id']} name check" for p in cat if p.get("source") and (p["source"], f"{p['id']}.jpg") not in named]+ if todo:+ sys.exit(f"not reviewed yet ({len(todo)}): {', '.join(todo[:8])} ...")+ sets = {s["set"]: s for source, s in load("name_*.json", "sets") if src.get(s["set"]) == source}+ fails = [x for source, x in load("fail_*.json", "fails") + load("dups*.json", "fails") if src.get(x["set"]) == source]panel = {}for x in fails:@@ -57,7 +73,8 @@ def main() -> None:views, set_notes = {}, {}for p in cat:pid, row = p["id"], {}- prev = old["views"].get(pid, {})+ # The previous run's file names belong to the old drawing until a merge has recorded the new source.+ prev = old["views"].get(pid, {}) if old.get("sources", {}).get(pid) == src[pid] else {}match = sets.get(pid, {}).get("match", "yes")if match != "yes":s = sets[pid]@@ -90,8 +107,8 @@ def main() -> None:photos[p["id"]] = rowp["photos"] = {v: r["file"] for v, r in row.items() if r["status"] == "pass"}- qc = {"schema": 1, "reviewed": a.date, "method": "docs/qc/README.md", "sets": set_notes, "views": views,- "photos": photos}+ qc = {"schema": 1, "reviewed": a.date, "method": "docs/qc/README.md", "sets": set_notes,+ "sources": {pid: s for pid, s in src.items() if s}, "views": views, "photos": photos}qc_path.write_text(json.dumps(qc, ensure_ascii=False, indent=1) + "\n")cat_path.write_text(json.dumps(cat, ensure_ascii=False, indent=1) + "\n")diff --git a/tools/review_sheets.py b/tools/review_sheets.pyindex 50eaad94..488d6dd8 100755--- a/tools/review_sheets.py+++ b/tools/review_sheets.py@@ -3,7 +3,8 @@Usage: python3 tools/review_sheets.py OUT_DIR [--mode MODE] [--passed] std=SRC sexy=SRC upper=SRC duo=SRCSRC is a source set (e.g. ~/Downloads/pose-gallery-std73); line art is read from SRC/img, photos from SRC/photo.-Only the series given are drawn, so one series can be reviewed on its own.+Only the series given are drawn, so one series can be reviewed on its own. Redrawn sets (catalog `source`) are drawn+only when their source is given too (digi=SRC), and only then; --only-source digi limits the run to them.Modes (each pairs with a prompt in docs/qc/):panels up to 3 views per sheet, 600x800 each review_prompt.md <id>__<view>-<view>.jpg@@ -50,6 +51,7 @@ def main() -> None:ap.add_argument("out")ap.add_argument("--mode", default="panels", choices=MODES)ap.add_argument("--passed", action="store_true")+ ap.add_argument("--only-source", default=None)ap.add_argument("srcs", nargs="+", metavar="series=SRC")a = ap.parse_args()srcs = {k: pathlib.Path(v).expanduser() for k, v in (s.split("=", 1) for s in a.srcs)}@@ -60,9 +62,10 @@ def main() -> None:qc = json.loads(qc_path.read_text()) if qc_path.exists() else {}n = 0for p in json.loads((ROOT / "data/catalog.json").read_text()):- if p["series"] not in srcs:+ line_src = p.get("source") or p["series"]+ if p["series"] not in srcs or line_src not in srcs or (a.only_source and p.get("source") != a.only_source):continue- src, pid = srcs[p["series"]], p["id"]+ src, pid = srcs[line_src if a.mode != "photo" else p["series"]], p["id"]expect = EXPECT[p["series"]] + (f" ({BODIES[p['bodies']]})" if p.get("bodies") else "")if a.mode == "photo":files = {v: r["file"] for v, r in qc.get("photos", {}).get(pid, {}).items()} | (p.get("photos") or {})diff --git a/tools/verify.py b/tools/verify.pyindex 7abe1324..199705e5 100755--- a/tools/verify.py+++ b/tools/verify.py@@ -4,6 +4,7 @@- every non-null catalog view has a `pass` in qc.json and exists in both tiers;- every null view has a non-pass qc status and a matching `gaps` entry (missing, line or structure);- every rating override in data/rating_overrides.json is applied;+- every redrawn pose (catalog `source`) was merged as such: qc.json `sources` names the same source;- every photo has a `pass` in qc.json photos and exists in both tiers; nothing under images/ is unreferenced."""import json, pathlib, sys@@ -22,6 +23,9 @@ def main() -> int:for pid, o in (json.loads(ov_path.read_text()) if ov_path.exists() else {}).items():if next((p["rating"] for p in cat if p["id"] == pid), None) != o["rating"]:errs.append(f"{pid}: rating should be {o['rating']} (data/rating_overrides.json)")+ sources = {p["id"]: p["source"] for p in cat if p.get("source")}+ if sources != qcd.get("sources", {}):+ errs.append("catalog sources differ from qc.json sources (run qc_merge.py after import_redraws.py)")ids = [p["id"] for p in cat]if len(ids) != len(set(ids)):errs.append("duplicate ids in catalog")