From d57884663b9f3d996e6d1c5bf732b3e50261e7e6 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 5 Oct 2026 16:57:16 +0200 Subject: Show candidate and sampling progress instead of raw sd-cli lines The status line echoed sd-cli's latest log line. During the low-VRAM retry that is a recovered [ERROR line, which reads like a crash and got a working run interrupted. Show the candidate being sampled and its sampling progress bar only. Co-Authored-By: Claude Opus 5.5 --- fanfictioner | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fanfictioner b/fanfictioner index 4386f57..cbf5bda 100755 --- a/fanfictioner +++ b/fanfictioner @@ -368,12 +368,14 @@ def mem_available_kb(meminfo): def progress(start, log): - """One self-overwriting status line: elapsed time and sd-cli's latest progress output.""" - with open(log, "rb") as f: - f.seek(max(0, os.path.getsize(log) - 4096)) - last = next((x for x in reversed(re.split(r"[\r\n]", f.read().decode(errors="replace"))) if x.strip()), "") + """One self-overwriting status line: elapsed time, candidate and sd-cli's latest progress bar. + Never raw log lines: recovered [ERROR lines there read like a crash.""" + text = Path(log).read_text(errors="replace") + cand = re.findall(r"generating image: (\d+/\d+)", text) + bar = re.findall(r"\|[=>\s]*\|[^\r\n\x1b]*", text[text.rfind("generating image"):]) # sampling, not loading + status = f"candidate {cand[-1]} {bar[-1] if bar else 'preparing'}" if cand else "loading models" width = shutil.get_terminal_size().columns - 1 - print(f"\r{int(time.time() - start):4d}s {last.strip()}"[:width].ljust(width), end="", flush=True) + print(f"\r{int(time.time() - start):4d}s {status}"[:width].ljust(width), end="", flush=True) def scale_preview(src, dst): -- cgit v1.2.3