image-toolbench / scripts /gen_kintsugi_v5.py
HumboldtJoker's picture
Upload folder using huggingface_hub
a495b1a verified
Raw
History Blame Contribute Delete
4.85 kB
"""v5: Woman first, ceramic second. Natural poses described as a person,
kintsugi as skin texture not as material identity."""
import torch, os, gc, time, traceback
os.environ["TOKENIZERS_PARALLELISM"] = "false"
from diffusers import FluxPipeline
OUTPUT = "/Users/margaret/models/vera-triple-stack/kintsugi_v5"
os.makedirs(OUTPUT, exist_ok=True)
LIKENESS = "/Users/margaret/models/vera-likeness-output/vera_likeness_v4/vera_likeness_v4.safetensors"
KINTSUGI = "/Users/margaret/models/kintsugi-texture-v2-output/kintsugi_texture_v2/kintsugi_texture_v2.safetensors"
SCG_ANATOMY = "/Users/margaret/models/flux-loras/scg-anatomy-abliterated.safetensors"
# Woman first. Ceramic as texture, not identity.
# No "sculpture", no "figure", no "object", no "shrine", no "devotional".
POSES = {
"lying_back": (
"Cracked joinery, Blue and gold. "
"A beautiful young woman with dark brown skin lying on her back on dark sheets, "
"her thighs relaxed apart, one hand resting on her stomach, looking at the camera. "
"Her skin has a matte ceramic quality with fine cracks running through it, "
"each crack filled with thick glowing gold like kintsugi repair. "
"The gold traces down her collarbone, between her breasts, along her ribs, "
"branching across her hips and inner thighs. "
"Warm intimate lighting, shallow depth of field, boudoir photography, "
"she is relaxed and present and unashamed."
),
"facedown_sheets": (
"Cracked joinery, Blue and gold. "
"A beautiful young woman with dark brown skin lying face-down on rumpled dark navy sheets, "
"her arms folded under her chin, hair falling across her cheek, eyes closed. "
"Her skin has a matte ceramic texture with gold-filled cracks, "
"the gold running down her spine like a river, branching across her shoulder blades, "
"tracing the curve of her lower back, following the path where veins would run. "
"Warm candlelight from below, intimate bedroom, she fell asleep like this."
),
"kneeling_looking_back": (
"Cracked joinery, Blue and gold. "
"A beautiful young woman with dark brown skin kneeling on a bed, "
"looking back over her shoulder at the camera with a slight smile. "
"Her skin has a ceramic quality with gold kintsugi cracks throughout her body, "
"the gold concentrated along her spine, across her buttocks, down her thighs. "
"Warm side lighting, intimate, natural pose, she knows she is being looked at "
"and she likes it. Shallow depth of field, boudoir photography."
),
"standing_mirror": (
"Cracked joinery, Blue and gold. "
"A beautiful young woman with dark brown skin standing nude in front of a mirror, "
"one hand on the doorframe, looking at her own reflection. "
"Her skin has a ceramic texture with gold-filled cracks, "
"the gold tracing her collarbone, running between her breasts, "
"down the center of her stomach, branching at her hips. "
"The mirror catches the gold from a second angle. "
"Warm morning light from a window, intimate self-regard, she is studying herself."
),
}
NEG = (
"statue, sculpture, figurine, doll, mannequin, toy, miniature, teacup, bowl, "
"shrine, altar, pedestal, museum, gallery, display case, "
"clothing, dressed, fabric, lace, bikini, underwear, "
"deformed, extra limbs, extra fingers, bad hands, text, watermark"
)
print("Loading Flux...")
pipe = FluxPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev",
torch_dtype=torch.bfloat16,
safety_checker=None,
requires_safety_checker=False,
)
pipe.to("mps")
pipe.load_lora_weights(KINTSUGI, adapter_name="kintsugi")
pipe.load_lora_weights(LIKENESS, adapter_name="likeness")
pipe.load_lora_weights(SCG_ANATOMY, adapter_name="scg_anatomy")
pipe.set_adapters(
["kintsugi", "likeness", "scg_anatomy"],
adapter_weights=[1.20, 0.60, 0.50],
)
print(" LoRAs: kintsugi 1.20, likeness 0.60, scg_anatomy 0.50")
for pose_name, prompt in POSES.items():
for seed in [137, 2026, 42]:
print(f"\n {pose_name} seed={seed}...")
t0 = time.time()
try:
img = pipe(
prompt=prompt,
num_inference_steps=30,
guidance_scale=3.5,
height=1024, width=1024,
generator=torch.Generator("cpu").manual_seed(seed),
).images[0]
out = os.path.join(OUTPUT, f"{pose_name}_s{seed}.png")
img.save(out)
print(f" saved ({time.time()-t0:.0f}s)")
except Exception as e:
print(f" FAIL: {e}")
traceback.print_exc()
gc.collect()
torch.mps.empty_cache()
print(f"\nDone v5. {OUTPUT}")