Files
lahrcarpetcleaning.com/tools/gen-missing-2.py
T
Concept Agent 307e452251 backup
2026-05-15 18:02:38 +02:00

61 lines
2.3 KiB
Python

"""Generate the 2 missing service images."""
import os, sys
try:
from google import genai
from google.genai import types
except ImportError:
os.system(f"{sys.executable} -m pip install google-genai --quiet")
from google import genai
from google.genai import types
API_KEY = os.environ.get("GEMINI_API_KEY", "AIzaSyB_1p8KvaT_rdNJGPs8HKk8bKsvUlcL6Kg")
OUT_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "assets", "images", "services")
client = genai.Client(api_key=API_KEY)
TARGETS = [
{
"name": "property-management",
"prompt": (
"View across three clean empty apartment living rooms, each with spotlessly clean "
"beige carpet showing fresh extraction lines after professional hot water extraction cleaning. "
"Bright neutral interiors ready for new tenants. Natural light, no furniture, "
"no people, no equipment. Professional real estate photography, ultra-realistic."
),
},
{
"name": "commercial-overview",
"prompt": (
"Professional carpet cleaning technician in a plain black shirt, shown from the side, "
"pushing a large upright extraction machine through a bright commercial building lobby. "
"Clean bright carpet behind the machine. No steam, no water spraying, no face visible. "
"Professional editorial photography, ultra-realistic."
),
},
]
for item in TARGETS:
out_path = os.path.join(OUT_DIR, f"{item['name']}.jpg")
print(f"Generating {item['name']}...")
try:
resp = client.models.generate_images(
model="imagen-4.0-generate-001",
prompt=item["prompt"],
config=types.GenerateImagesConfig(
number_of_images=1,
aspect_ratio="4:3",
output_mime_type="image/jpeg",
safety_filter_level="block_low_and_above",
),
)
if resp.generated_images:
b = resp.generated_images[0].image.image_bytes
with open(out_path, "wb") as f:
f.write(b)
print(f" Saved ({len(b)//1024}KB)")
else:
print(f" No image returned")
except Exception as e:
print(f" Error: {e}")
print("Done.")