← back to Dw Collection Banner Audit
gen_candidates.py
37 lines
#!/usr/bin/env python3
"""Generate 5 ORIGINAL text-to-image room-render candidates (no external image copied)
for the logo-only collections. Settlement-safe prompts. NOT auto-landed."""
import json, os, base64, time, urllib.request
HERE = os.path.dirname(os.path.abspath(__file__))
GKEY = os.environ["GEMINI_API_KEY"]; MODEL = "gemini-2.5-flash-image"
OUT = os.path.join(HERE, "room_renders_candidates"); os.makedirs(OUT, exist_ok=True)
BASE = ("Photorealistic luxury interior photograph, wide 16:9 banner composition, natural lighting, "
"tasteful furniture, magazine editorial quality, no text, no watermark, no brand logos, no monograms. ")
PROMPTS = {
"paul-montgomery-all-products": BASE + "The main wall features an elegant hand-painted decorative mural in soft muted blues and creams — an abstract architectural landscape scene. NO birds, NO butterflies, NO tropical palm or banana foliage. Refined living room.",
"paul-montgomery-murals": BASE + "The main wall is a large hand-painted panoramic mural in gentle sepia and sage tones depicting a serene abstract garden-architecture scene. NO birds, NO butterflies, NO tropical palm or banana leaves. Elegant dining room.",
"phillipe-romano-faux-leathers-upholstery-more": BASE + "The main wall is clad in rich embossed faux-leather wallcovering with a subtle pebbled texture in warm cognac tone. Modern room with leather and brushed-brass accents.",
"collezione-italia": BASE + "The main wall is an ornate tone-on-tone Italian damask wallcovering in soft champagne and pearl. Opulent Milanese-glamour room with marble and gilt accents.",
"hermes": BASE + "The main wall is an understated geometric textured wallcovering in warm neutral taupe. Sophisticated refined room with leather and walnut accents, quiet luxury.",
}
def gen(handle, prompt):
body = json.dumps({"contents": [{"parts": [{"text": prompt}]}],
"generationConfig": {"imageConfig": {"aspectRatio": "16:9"}}}).encode()
url = f"https://generativelanguage.googleapis.com/v1beta/models/{MODEL}:generateContent?key={GKEY}"
res = json.load(urllib.request.urlopen(urllib.request.Request(url, data=body, headers={"Content-Type": "application/json"}), timeout=120))
for part in res["candidates"][0]["content"]["parts"]:
d = part.get("inline_data") or part.get("inlineData")
if d:
out = os.path.join(OUT, f"{handle}.png"); open(out, "wb").write(base64.b64decode(d["data"])); return out
return None
for h, p in PROMPTS.items():
try:
out = gen(h, p); print(f" {'OK ' if out else 'FAIL'} {h}")
except Exception as e:
print(f" ERR {h}: {str(e)[:90]}")
time.sleep(1.2)
print("candidates in", OUT)