From 10018d8db7b92bce496301322a1e6ca9b9ede209 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 8 Jul 2026 15:37:48 +0200 Subject: Add width/height flags and correct default host paths Pre-plan prep: -W/-H flags on generate.py with multiple-of-8 validation, generate() gains width/height params, copyright line normalized, and the wrapper defaults updated to the real host output/cache paths. Co-Authored-By: Claude Opus 4.8 --- generate.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'generate.py') diff --git a/generate.py b/generate.py index ba437ae..5eed627 100644 --- a/generate.py +++ b/generate.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (C) 2026 Danilo +# Copyright (C) 2026 Danilo M. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -53,7 +53,7 @@ def build_pipe(): return pipe -def generate(pipe, prompt, negative, steps, guidance, seed): +def generate(pipe, prompt, negative, steps, guidance, seed, width, height): generator = None if seed is not None: generator = torch.Generator(device="xpu").manual_seed(seed) @@ -65,6 +65,8 @@ def generate(pipe, prompt, negative, steps, guidance, seed): num_inference_steps=steps, guidance_scale=guidance, generator=generator, + width=width, + height=height, ).images[0] torch.xpu.synchronize() elapsed = time.time() - t @@ -89,6 +91,20 @@ def main(): default=7.0, help="Guidance scale / CFG (default: 7.0).", ) + ap.add_argument( + "-W", + "--width", + type=int, + default=1024, + help="Image width, multiple of 8 (default: 1024).", + ) + ap.add_argument( + "-H", + "--height", + type=int, + default=1024, + help="Image height, multiple of 8 (default: 1024).", + ) ap.add_argument( "--seed", type=int, @@ -103,6 +119,9 @@ def main(): ) args = ap.parse_args() + if args.width % 8 or args.height % 8: + ap.error("--width and --height must be multiples of 8 (SDXL constraint).") + OUT_DIR.mkdir(parents=True, exist_ok=True) if args.out: @@ -117,7 +136,8 @@ def main(): print(f"Loaded in {time.time() - t0:.1f}s", file=sys.stderr) image, elapsed = generate( - pipe, args.prompt, args.negative, args.steps, args.guidance, args.seed + pipe, args.prompt, args.negative, args.steps, args.guidance, args.seed, + args.width, args.height, ) image.save(out_path) print(f"Generated in {elapsed:.2f}s") -- cgit v1.2.3