56 lines
2.1 KiB
Python
56 lines
2.1 KiB
Python
"""Regenerate commercial-overview.jpg with a clear commercial carpet scene."""
|
|
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)
|
|
|
|
PROMPTS = [
|
|
(
|
|
"Wide shot of a modern commercial office building lobby with clean grey carpet throughout. "
|
|
"Professional corporate interior, glass doors, white walls, overhead lighting. "
|
|
"The carpet is spotless and freshly cleaned — uniform, well-maintained. "
|
|
"No people. No machines. No equipment. Professional architectural photography, ultra-realistic."
|
|
),
|
|
(
|
|
"Wide interior shot of a bright commercial building corridor with clean, dark grey commercial carpet. "
|
|
"Modern office environment, glass partitions, professional lighting. "
|
|
"The carpet looks freshly cleaned and spotless. "
|
|
"No people, no equipment. Professional photography, ultra-realistic."
|
|
),
|
|
]
|
|
|
|
out_path = os.path.join(OUT_DIR, "commercial-overview.jpg")
|
|
|
|
for i, prompt in enumerate(PROMPTS):
|
|
print(f"Attempt {i+1}...")
|
|
try:
|
|
resp = client.models.generate_images(
|
|
model="imagen-4.0-generate-001",
|
|
prompt=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)")
|
|
break
|
|
else:
|
|
print("No image returned")
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
|
|
print("Done.")
|