diff options
| -rw-r--r-- | README.md | 7 | ||||
| -rwxr-xr-x | fanfictioner | 17 |
2 files changed, 16 insertions, 8 deletions
@@ -11,8 +11,9 @@ image stage. Pages land in the book-reader library as `NNN.png`. - llama-server in router mode on `localhost:8181` serving `Gemma4-12B-qat-mtp` - `sd-cli` with Vulkan, models under `/data/LLM-models/SD` - ImageMagick 7 (`magick`), `$EDITOR`, `notify-send` (libnotify), and kitty for - inline previews (elsewhere candidates open with `xdg-open`); a live preview of - the candidate being rendered opens in `magick display`, floated under Hyprland + inline previews (elsewhere candidates open with `xdg-open`); with `--preview`, + a live view of the candidate being rendered opens in `magick display`, floated + under Hyprland - `~/.config/book-reader.conf` with a `LIBRARY="..."` line ## Usage @@ -38,7 +39,7 @@ Editing the story after plan.md exists asks whether Gemma should revise the plan to match it, draft a new one (the old one is kept as plan.md.bak), or keep the plan as it is. Editing only the frontmatter is applied without Gemma. - fanfictioner story.md [--base zimage|krea2] + fanfictioner story.md [--base zimage|krea2] [--preview] fanfictioner --selftest Work files go to a directory named after the story (`stories/rooftop.md` -> diff --git a/fanfictioner b/fanfictioner index 440a870..9917540 100755 --- a/fanfictioner +++ b/fanfictioner @@ -442,6 +442,7 @@ def run_sd(args, log, preview=None): LOG = None # wd / "run.log", set by main +PREVIEW = False # --preview, set by main def log(msg): @@ -476,10 +477,13 @@ def generate(d, profile, prompt, size, refs=()): seed = random.randint(0, 2**31 - 4) log = d / f"{seed}.log" print(f"sd-cli {profile}, seed {seed} ...", flush=True) - preview = d / "preview.png" # rewritten every step, one candidate after the other - preview.unlink(missing_ok=True) - err = run_sd(sd_args(profile, prompt, d / f"{seed}_%d.png", size, seed, refs) - + ["--preview", "proj", "--preview-path", str(preview)], log, preview) + args = sd_args(profile, prompt, d / f"{seed}_%d.png", size, seed, refs) + preview = None + if PREVIEW: + preview = d / "preview.png" # rewritten every step, one candidate after the other + preview.unlink(missing_ok=True) + args += ["--preview", "proj", "--preview-path", str(preview)] + err = run_sd(args, log, preview) files = [d / f"{seed}_{i}.png" for i in (1, 2, 3)] if not err and not all(f.exists() for f in files): err = "sd-cli wrote no output" @@ -916,6 +920,8 @@ def main(): ap.add_argument("story", nargs="?", type=Path, help="story idea in free prose") ap.add_argument("--base", choices=("zimage", "krea2"), default="zimage", help="base model for pages without a Model: line") + ap.add_argument("--preview", action="store_true", + help="live window showing each candidate while it renders") ap.add_argument("--selftest", action="store_true", help="run built-in checks and exit") a = ap.parse_args() if a.selftest: @@ -933,7 +939,8 @@ def main(): lib = None if not lib: sys.exit(f"set LIBRARY in {CONF}") - global LOG + global LOG, PREVIEW + PREVIEW = a.preview wd = a.story.with_suffix("") LOG = wd / "run.log" log(f"start, base model {a.base}") |
