aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfanfictioner46
1 files changed, 46 insertions, 0 deletions
diff --git a/fanfictioner b/fanfictioner
index c993761..6a9581f 100755
--- a/fanfictioner
+++ b/fanfictioner
@@ -524,6 +524,41 @@ def plan_stage(story, wd):
sys.exit(0)
+def shrink(src, dst, geom):
+ dst.parent.mkdir(parents=True, exist_ok=True)
+ subprocess.run(["magick", str(src), "-resize", geom, str(dst)], check=True)
+ return dst
+
+
+def refs_stage(chars, wd):
+ for c in chars:
+ print(f"\n== reference sheet: {c['name']}")
+ pick = review(wd / "cand" / f"ref_{c['name']}", "zimage", c["turnaround_prompt"], SIZES["turnaround"])
+ keep(pick, wd / "refs" / f"{c['name']}.png")
+
+
+def page_stage(p, wd, out, base):
+ """Base scene, then chained head edits; each pick kept in cand/pNNN so a quit resumes mid-page."""
+ d = wd / "cand" / f"p{p['n']:03d}"
+ size = SIZES[p["orientation"]]
+ scene = d / "base.png"
+ if not scene.exists():
+ print(f"\n== page {p['n']}: base scene")
+ keep(review(d / "base", p["model"] or base, p["base_prompt"], size), scene)
+ for i, e in enumerate(p["edits"], 1):
+ nxt = d / f"edit{i}.png"
+ if not nxt.exists():
+ print(f"\n== page {p['n']}: edit {i} ({', '.join(e['characters'])})")
+ refs = [shrink(scene, d / f"edit{i}_in.png", SHRINK[p["orientation"]])]
+ refs += [shrink(wd / "refs" / f"{n}.png", wd / "cand" / "refs_small" / f"{n}.png", SHRINK["ref"])
+ for n in e["characters"]]
+ pick = review(d / f"edit{i}", "qwen_edit", e["prompt"], size, refs, skip=True)
+ keep(pick or scene, nxt)
+ scene = nxt
+ keep(scene, out)
+ print(f"page {p['n']} -> {out}")
+
+
def selftest():
plan = parse_plan(SAMPLE_PLAN)
assert (plan["title"], plan["series"], plan["book"]) == ("Rooftop", "Test Series", "Book One"), plan
@@ -654,6 +689,17 @@ def main():
return selftest()
if not a.story:
ap.error("story file required")
+ try:
+ lib = load_conf()["LIBRARY"]
+ wd = a.story.with_suffix("")
+ pj = plan_stage(a.story, wd)
+ chars, pages = todo(pj, wd, lib)
+ refs_stage(chars, wd)
+ for p in pages:
+ page_stage(p, wd, page_path(lib, pj, p["n"]), a.base)
+ print(f"\ndone: {page_path(lib, pj, 1).parent}")
+ except (KeyboardInterrupt, EOFError):
+ sys.exit("\ninterrupted, run again to resume")
if __name__ == "__main__":