diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-08 15:37:48 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-08 15:37:48 +0200 |
| commit | 10018d8db7b92bce496301322a1e6ca9b9ede209 (patch) | |
| tree | fd5b919a5d103aa03eb9f9fac0c8185a86c91d9f /generate.py | |
| parent | 15f07530fa6a8854784107b4f6a4425e42f63639 (diff) | |
| download | imggen-10018d8db7b92bce496301322a1e6ca9b9ede209.tar.gz imggen-10018d8db7b92bce496301322a1e6ca9b9ede209.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'generate.py')
| -rw-r--r-- | generate.py | 26 |
1 files changed, 23 insertions, 3 deletions
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. <danix@danix.xyz> # # 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 @@ -90,6 +92,20 @@ def main(): 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, default=None, @@ -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") |
