updated images with ai images
This commit is contained in:
@@ -0,0 +1,292 @@
|
||||
"""
|
||||
Generate all site images via FLUX.1 Schnell GGUF through ComfyUI.
|
||||
FLUX Schnell: 4 steps, cfg=1.0, no negative prompt, photorealistic.
|
||||
Run after ComfyUI restart: python3 tools/gen-images-flux.py
|
||||
"""
|
||||
import json, time, urllib.request, os, random, io
|
||||
|
||||
COMFY = "http://localhost:8188"
|
||||
HERO_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "assets", "images", "hero")
|
||||
SVC_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "assets", "images", "services")
|
||||
|
||||
IMAGES = [
|
||||
# --- HERO IMAGES ---
|
||||
{"filename": "hero-carpet-cleaning.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low-angle 35mm lens perspective looking across thick plush cream carpet in an upstate New York living room, "
|
||||
"carpet fibers razor sharp in foreground, couch and coffee table receding into shallow bokeh background, "
|
||||
"warm afternoon window light raking across carpet texture, Finger Lakes farmhouse interior, "
|
||||
"no people, ultra-realistic architectural photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-stairs.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"dramatic low 35mm angle looking up a clean carpeted staircase from floor level, "
|
||||
"light grey carpet runner sharp and textured in foreground steps, wood banister receding diagonally, "
|
||||
"bright daylight flooding from above, shallow depth of field, "
|
||||
"no people, ultra-realistic interior photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-upholstery.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"50mm lens low corner angle across a bright residential living room, "
|
||||
"plush linen fabric sofa arm sharp in near foreground, clean armchair and window receding with bokeh, "
|
||||
"afternoon countryside light through window, shallow depth of field, "
|
||||
"no people, ultra-realistic interior photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-floors.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low 24mm angle pressed to gleaming light oak hardwood floor, "
|
||||
"floor grain razor sharp in extreme foreground receding to hallway vanishing point, "
|
||||
"white walls, natural light streaming in, shallow depth of field, "
|
||||
"no people, ultra-realistic interior photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-area-rugs.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low 35mm angle looking across a hand-knotted oriental rug from floor level, "
|
||||
"rich red and gold rug fibers sharp in foreground, hardwood floor and room receding into bokeh, "
|
||||
"cozy farmhouse living room, warm natural light, shallow depth of field, "
|
||||
"no people, ultra-realistic interior photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-add-ons.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low 35mm angle across a clean beige bedroom carpet, "
|
||||
"carpet pile sharp and detailed in near foreground, wooden bed frame and sheer curtained window receding, "
|
||||
"crisp morning light, shallow depth of field, "
|
||||
"no people, no machines, ultra-realistic interior photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-commercial.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low 24mm wide-angle lens across a modern corporate lobby floor, "
|
||||
"dark charcoal commercial carpet sharp in extreme foreground receding to glass entrance doors, "
|
||||
"recessed ceiling lights creating depth, strong vanishing point perspective, "
|
||||
"no people, ultra-realistic architectural photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-offices.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low 24mm angle across clean grey carpet tiles in a modern open-plan office, "
|
||||
"carpet tile seams sharp in foreground receding to rows of empty desks and glass partitions, "
|
||||
"professional overhead lighting, strong linear perspective, "
|
||||
"no people, ultra-realistic architectural photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-vacation-rentals.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low 35mm angle across clean beige carpet in a Finger Lakes cottage living room, "
|
||||
"carpet fibers sharp in foreground, stone fireplace and lake-view window receding with bokeh, "
|
||||
"wooden ceiling beams, warm inviting light, shallow depth of field, "
|
||||
"no people, ultra-realistic interior photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-hotels.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low 24mm lens looking down a long hotel corridor from floor level, "
|
||||
"patterned burgundy carpet runner sharp in extreme foreground receding to vanishing point, "
|
||||
"warm wall sconces lining white walls, numbered doors converging in perspective, "
|
||||
"no people, ultra-realistic hospitality photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-retail.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low 35mm diagonal angle across clean light grey carpet in an upscale retail showroom, "
|
||||
"carpet surface sharp in foreground, minimalist display fixtures and storefront windows receding with bokeh, "
|
||||
"bright track lighting overhead, shallow depth of field, "
|
||||
"no people, ultra-realistic architectural photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-property-management.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low 35mm angle across fresh neutral carpet in an empty move-in ready apartment, "
|
||||
"carpet texture sharp in foreground, bare white walls and bright windows receding, "
|
||||
"clean real estate photography perspective, shallow depth of field, "
|
||||
"no people, ultra-realistic real estate photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-about.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low 35mm angle from lawn level looking up at a classic upstate New York suburban home, "
|
||||
"green grass blades sharp in extreme foreground, inviting house facade receding upward, "
|
||||
"mature trees and clear blue sky, warm summer afternoon, "
|
||||
"no people, ultra-realistic real estate photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-service-area.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low horizon 24mm wide-angle Finger Lakes landscape, "
|
||||
"green vineyard vines sharp in foreground receding to rolling hills and calm lake, "
|
||||
"golden hour light casting long shadows, strong depth and distance, "
|
||||
"no people, ultra-realistic landscape photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-living-room.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"low 35mm corner angle across a spacious residential living room, "
|
||||
"plush light grey carpet sharp and textured in foreground, large sectional sofa and bay windows receding with bokeh, "
|
||||
"warm afternoon sunlight, shallow depth of field, "
|
||||
"no people, ultra-realistic interior photography, 16:9"
|
||||
)},
|
||||
{"filename": "hero-clean-result.jpg", "dir": HERO_DIR, "prompt": (
|
||||
"extreme low 50mm macro angle pressed to immaculate freshly cleaned residential carpet, "
|
||||
"individual carpet fibers razor sharp in foreground, pile receding into soft bokeh, "
|
||||
"raking natural light revealing deep clean texture and uniform pile height, "
|
||||
"no people, ultra-realistic macro carpet photography, 16:9"
|
||||
)},
|
||||
# --- SERVICE CARD IMAGES ---
|
||||
{"filename": "carpet-cleaning.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 35mm angle looking across plush clean beige carpet in a residential living room, "
|
||||
"carpet fibers sharp in foreground, couch and window receding into bokeh, "
|
||||
"warm afternoon light, shallow depth of field, no people, ultra-realistic interior photography"
|
||||
)},
|
||||
{"filename": "stairs-cleaning.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 35mm angle looking up clean grey carpeted stairs from bottom step, "
|
||||
"carpet texture sharp on nearest step, stairs receding diagonally upward, "
|
||||
"wood banister, bright light from above, no people, ultra-realistic interior photography"
|
||||
)},
|
||||
{"filename": "upholstery-cleaning.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 50mm angle across a clean plush linen fabric sofa arm, "
|
||||
"fabric weave sharp in foreground, living room receding with bokeh, "
|
||||
"warm light, shallow depth of field, no people, ultra-realistic interior photography"
|
||||
)},
|
||||
{"filename": "floor-cleaning.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 24mm angle pressed to gleaming light oak hardwood floor, "
|
||||
"wood grain razor sharp in extreme foreground receding down hallway, "
|
||||
"natural light, no people, ultra-realistic interior photography"
|
||||
)},
|
||||
{"filename": "area-rug-cleaning.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 35mm angle across a vibrant clean oriental rug from floor level, "
|
||||
"rug fibers and pattern sharp in foreground, hardwood floor and room receding, "
|
||||
"warm light, shallow depth of field, no people, ultra-realistic interior photography"
|
||||
)},
|
||||
{"filename": "add-ons.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 35mm angle across clean beige bedroom carpet, "
|
||||
"carpet pile sharp in foreground, bed frame and curtained window receding with bokeh, "
|
||||
"morning light, no people, ultra-realistic interior photography"
|
||||
)},
|
||||
{"filename": "commercial-overview.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 24mm angle across dark commercial carpet in a corporate lobby, "
|
||||
"carpet surface sharp in foreground receding to glass entrance, "
|
||||
"strong vanishing point, no people, ultra-realistic architectural photography"
|
||||
)},
|
||||
{"filename": "vacation-rentals.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 35mm angle across clean carpet in a Finger Lakes cottage living room, "
|
||||
"carpet sharp in foreground, stone fireplace and window receding with bokeh, "
|
||||
"rustic warm decor, no people, ultra-realistic interior photography"
|
||||
)},
|
||||
{"filename": "office-spaces.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 24mm angle across grey carpet tiles in a modern open office, "
|
||||
"tile seams sharp in foreground, empty desks receding with linear perspective, "
|
||||
"professional lighting, no people, ultra-realistic architectural photography"
|
||||
)},
|
||||
{"filename": "hotels-inns.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 24mm angle down a hotel corridor, patterned carpet runner sharp in foreground, "
|
||||
"corridor receding to vanishing point, warm wall sconces, "
|
||||
"no people, ultra-realistic hospitality photography"
|
||||
)},
|
||||
{"filename": "retail-showrooms.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 35mm diagonal angle across light grey carpet in an upscale retail showroom, "
|
||||
"carpet sharp in foreground, display fixtures and track lighting receding with bokeh, "
|
||||
"no people, ultra-realistic architectural photography"
|
||||
)},
|
||||
{"filename": "property-management.jpg", "dir": SVC_DIR, "prompt": (
|
||||
"low 35mm angle across fresh neutral carpet in an empty clean apartment, "
|
||||
"carpet texture sharp in foreground, white walls and windows receding, "
|
||||
"no people, ultra-realistic real estate photography"
|
||||
)},
|
||||
]
|
||||
|
||||
|
||||
def build_workflow(prompt, seed=None):
|
||||
if seed is None:
|
||||
seed = random.randint(0, 2**32)
|
||||
return {
|
||||
"1": {
|
||||
"class_type": "UnetLoaderGGUF",
|
||||
"inputs": {"unet_name": "flux1-schnell-Q8_0.gguf"},
|
||||
},
|
||||
"2": {
|
||||
"class_type": "DualCLIPLoader",
|
||||
"inputs": {
|
||||
"clip_name1": "t5xxl_fp8_e4m3fn.safetensors",
|
||||
"clip_name2": "clip_l.safetensors",
|
||||
"type": "flux",
|
||||
},
|
||||
},
|
||||
"3": {
|
||||
"class_type": "VAELoader",
|
||||
"inputs": {"vae_name": "ae.safetensors"},
|
||||
},
|
||||
"4": {
|
||||
"class_type": "CLIPTextEncode",
|
||||
"inputs": {"clip": ["2", 0], "text": prompt},
|
||||
},
|
||||
"5": {
|
||||
"class_type": "EmptyLatentImage",
|
||||
"inputs": {"batch_size": 1, "height": 576, "width": 1024},
|
||||
},
|
||||
"6": {
|
||||
"class_type": "KSampler",
|
||||
"inputs": {
|
||||
"cfg": 1.0,
|
||||
"denoise": 1.0,
|
||||
"latent_image": ["5", 0],
|
||||
"model": ["1", 0],
|
||||
"negative": ["4", 0],
|
||||
"positive": ["4", 0],
|
||||
"sampler_name": "euler",
|
||||
"scheduler": "simple",
|
||||
"seed": seed,
|
||||
"steps": 4,
|
||||
},
|
||||
},
|
||||
"7": {
|
||||
"class_type": "VAEDecode",
|
||||
"inputs": {"samples": ["6", 0], "vae": ["3", 0]},
|
||||
},
|
||||
"8": {
|
||||
"class_type": "SaveImage",
|
||||
"inputs": {"filename_prefix": "flux_lahr", "images": ["7", 0]},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def queue_prompt(workflow):
|
||||
data = json.dumps({"prompt": workflow}).encode()
|
||||
req = urllib.request.Request(
|
||||
f"{COMFY}/prompt", data=data,
|
||||
headers={"Content-Type": "application/json"}
|
||||
)
|
||||
with urllib.request.urlopen(req) as resp:
|
||||
return json.loads(resp.read())["prompt_id"]
|
||||
|
||||
|
||||
def wait_for_result(prompt_id, timeout=600):
|
||||
start = time.time()
|
||||
while time.time() - start < timeout:
|
||||
try:
|
||||
with urllib.request.urlopen(f"{COMFY}/history/{prompt_id}") as resp:
|
||||
hist = json.loads(resp.read())
|
||||
if prompt_id in hist:
|
||||
entry = hist[prompt_id]
|
||||
status = entry.get("status", {}).get("status_str", "")
|
||||
if status == "error":
|
||||
msgs = entry.get("status", {}).get("messages", [])
|
||||
print(f" COMFYUI ERROR: {msgs}", flush=True)
|
||||
return None
|
||||
for node_out in entry.get("outputs", {}).values():
|
||||
if "images" in node_out:
|
||||
return node_out["images"]
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(5)
|
||||
return None
|
||||
|
||||
|
||||
def download_image(img_info, out_path):
|
||||
fname = img_info["filename"]
|
||||
subfolder = img_info.get("subfolder", "")
|
||||
img_type = img_info.get("type", "output")
|
||||
url = f"{COMFY}/view?filename={fname}&subfolder={subfolder}&type={img_type}"
|
||||
with urllib.request.urlopen(url) as resp:
|
||||
data = resp.read()
|
||||
try:
|
||||
from PIL import Image
|
||||
img = Image.open(io.BytesIO(data)).convert("RGB")
|
||||
img.save(out_path, "JPEG", quality=92)
|
||||
print(f" OK: {os.path.basename(out_path)} ({os.path.getsize(out_path)//1024}KB)", flush=True)
|
||||
except ImportError:
|
||||
png_path = out_path.replace(".jpg", ".png")
|
||||
with open(png_path, "wb") as f:
|
||||
f.write(data)
|
||||
print(f" OK (PNG): {png_path}", flush=True)
|
||||
|
||||
|
||||
total = len(IMAGES)
|
||||
for i, spec in enumerate(IMAGES):
|
||||
out_path = os.path.join(spec["dir"], spec["filename"])
|
||||
print(f"\n[{i+1}/{total}] {spec['filename']}", flush=True)
|
||||
workflow = build_workflow(spec["prompt"])
|
||||
prompt_id = queue_prompt(workflow)
|
||||
print(f" queued {prompt_id[:8]}...", flush=True)
|
||||
images = wait_for_result(prompt_id)
|
||||
if images:
|
||||
download_image(images[0], out_path)
|
||||
else:
|
||||
print(f" FAILED (timeout)", flush=True)
|
||||
|
||||
print("\nAll done.", flush=True)
|
||||
Reference in New Issue
Block a user