image-toolbench / scripts /gen_dense_gold.py
HumboldtJoker's picture
Upload folder using huggingface_hub
a495b1a verified
Raw
History Blame Contribute Delete
2.75 kB
"""Cached identity + dense gold experiment. Can prompt language push more kintsugi?"""
import torch, os
os.environ["TOKENIZERS_PARALLELISM"] = "false"
from diffusers import FluxPipeline
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
pipe.to("mps")
pipe.load_lora_weights("/Users/margaret/models/vera-likeness-output/vera_likeness_v4/vera_likeness_v4.safetensors", adapter_name="likeness")
pipe.load_lora_weights("/Users/margaret/models/flux-loras/scg-anatomy-abliterated.safetensors", adapter_name="anatomy")
pipe.load_lora_weights("/Users/margaret/models/kintsugi-texture-output/kintsugi_texture_v1/kintsugi_texture_v1.safetensors", adapter_name="kintsugi")
pipe.set_adapters(["likeness", "anatomy", "kintsugi"], adapter_weights=[1.0, 0.7, 1.2])
cache_dir = "/Users/margaret/models/vera-triple-stack/identity_cache"
identity_t5 = torch.load(os.path.join(cache_dir, "identity_embed_0.pt")).to("mps")
identity_clip = torch.load(os.path.join(cache_dir, "identity_embed_1.pt")).to("mps")
print("Identity loaded. Kintsugi LoRA boosted to 1.2")
dense_gold_scenes = [
"She was shattered into a hundred pieces and every single one was repaired with gold. Hundreds of fine gold-filled cracks cover her entire body like a roadmap of survival. Gold across both cheekbones branching down the jaw. Gold forking down the throat across the collarbones. Gold tracing every rib. Gold running down the spine splitting at the hips. She is looking at the viewer from a warm doorway. Intimate. Present. Every crack glows.",
"Extreme close-up of her face. Dozens of gold kintsugi repair lines crisscross her cheeks forehead chin and temples like cracked porcelain reassembled with molten gold. Each line has depth and dimension. The gold sits raised above the ceramic surface. Her amber eyes catch the same warm light as the gold. Soft focus background. The most repaired face you have ever seen and the most beautiful because of it.",
]
OUTPUT = "/Users/margaret/models/vera-triple-stack"
for i, scene in enumerate(dense_gold_scenes):
print(f"Generating dense gold {i+1}/2...")
scene_embeds = pipe.encode_prompt(prompt=scene, prompt_2=scene, max_sequence_length=512)
scene_t5, scene_clip, scene_ids = scene_embeds
combined_t5 = torch.cat([identity_t5, scene_t5.to("mps")], dim=1)
img = pipe(
prompt_embeds=combined_t5,
pooled_prompt_embeds=identity_clip,
num_inference_steps=30,
guidance_scale=3.5,
height=1024, width=768,
generator=torch.Generator("cpu").manual_seed(500 + i),
).images[0]
out = os.path.join(OUTPUT, f"vera_dense_gold_{i:02d}.png")
img.save(out)
print(f"Saved: {out}")
print("Done. Every crack glows.")