aboutsummaryrefslogtreecommitdiffstats
path: root/generate.py
diff options
context:
space:
mode:
Diffstat (limited to 'generate.py')
-rw-r--r--generate.py26
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")