aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-08 15:37:48 +0200
committerDanilo M. <danix@danix.xyz>2026-07-08 15:37:48 +0200
commit10018d8db7b92bce496301322a1e6ca9b9ede209 (patch)
treefd5b919a5d103aa03eb9f9fac0c8185a86c91d9f
parent15f07530fa6a8854784107b4f6a4425e42f63639 (diff)
downloadimggen-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>
-rw-r--r--generate.py26
-rw-r--r--imggen4
2 files changed, 25 insertions, 5 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")
diff --git a/imggen b/imggen
index 374c326..39f0bb6 100644
--- a/imggen
+++ b/imggen
@@ -19,10 +19,10 @@ set -euo pipefail
IMAGE="imggen:local"
# Where generated images land on the host. Override with IMGGEN_OUT.
-OUT_DIR="${IMGGEN_OUT:-$HOME/imggen-out}"
+OUT_DIR="${IMGGEN_OUT:-$HOME/Pictures/AI-gen}"
# Persistent model cache on the host. Override with IMGGEN_CACHE.
-CACHE_DIR="${IMGGEN_CACHE:-$HOME/.cache/imggen-models}"
+CACHE_DIR="${IMGGEN_CACHE:-/data/LLM-models/imggen-models}"
mkdir -p "$OUT_DIR" "$CACHE_DIR"