Files
Dolon (Agent) 50fce524ed
BetterLeaks / scan (push) Successful in 56s
Add --skip-tier-subfolder flag to render scripts
Allows outputting directly to base path for establishment-specific brothels:

# Pool courtesans (with tier subfolder):
python3 scripts/render_topless_az_aberx.py --tier Modest --output-base .../Courtesans

# Establishment-specific (no tier subfolder):
python3 scripts/render_topless_az_aberx.py --tier Modest --output-base .../Jolly_Brothel/Courtesans --skip-tier-subfolder

This supports multi-tier establishments while keeping clean single-tier paths.
2026-03-26 11:50:21 +00:00

230 lines
10 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Tier-independent Teasing More A-E renderer.
Usage: python3 render_teasing_more_ae.py --tier Wealthy [--workers 25] [--output-base /path]
"""
import argparse, base64, json, subprocess, time, os, sys
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor, as_completed
import requests
def main():
parser = argparse.ArgumentParser(description='Render Teasing More A-E for a courtesan tier')
parser.add_argument('--tier', required=True, help='Tier name (e.g., Wealthy, Comfortable)')
parser.add_argument('--workers', type=int, default=25, help='Concurrent workers (default: 25)')
parser.add_argument('--skip-tier-subfolder', action='store_true', help='Output directly to base (skip tier subfolder)')
parser.add_argument('--output-base', default='/home/rick/output/to-dnd-session-rclone/Grok-NPCs/Courtesans',
help='Base output directory')
parser.add_argument('--manifest-dir', default='/home/rick/.openclaw/workspace/memory/npc-run-manifests',
help='Manifest directory for identity lookup')
args = parser.parse_args()
tier_dir = Path(args.output_base) if args.skip_tier_subfolder else Path(args.output_base) / args.tier
ref_dir = tier_dir / 'Teasing'
out_dir = tier_dir / 'Teasing More'
out_dir.mkdir(parents=True, exist_ok=True)
# Load identities from manifests
identity_by_name = {}
manifest_dir = Path(args.manifest_dir)
for p in sorted([p for p in manifest_dir.glob('*.json') if 'payloads' not in p.name],
key=lambda p: p.stat().st_mtime, reverse=True):
try:
data = json.load(p.open())
except Exception:
continue
for npc in data.get('individuals', []):
n = npc.get('name')
if n not in identity_by_name:
identity_by_name[n] = npc
for pair in data.get('pairs', []):
for npc in pair.get('npcs', []):
n = npc.get('name')
if n not in identity_by_name:
identity_by_name[n] = npc
for n, npc in data.get('npc_profiles', {}).items():
if n not in identity_by_name:
identity_by_name[n] = npc
# Get API key
key = subprocess.check_output(['bash', '-lc', 'pass show x.ai/apikey | head -n1']).decode().strip()
headers = {"Authorization": f"Bearer {key}", "Content-Type": "application/json"}
API_URL = "https://api.x.ai/v1/images/edits"
NEGATIVE_TEXT = "no text, no labels, no captions, no logos, no watermark, no signage, no letters, no symbols, no UI overlays"
anti_modern = (
"Strict medieval Norse look: no bathrobes, no knit sweaters/cardigans, no modern trousers/pants, "
"no lace-up modern boots, no tufted upholstery, no modern cushions/pillows, no folded towels, "
"no modern plumbing/fixtures, no contemporary fabrics or cuts."
)
pose_variants = {
'A': 'standing relaxed, hands at sides',
'B': 'seated on a cushioned bench, relaxed posture',
'C': 'leaning lightly against a carved post',
'D': 'walking slowly with a small step',
'E': 'adjusting the neckline with one hand',
}
def data_url(path: Path):
return "data:image/jpeg;base64," + base64.b64encode(path.read_bytes()).decode()
def extract_eye(identity: str):
for part in identity.split(';'):
if 'eye' in part.lower():
return part.strip()
return None
def build_prompt_single(ref_name, tag, identity_map):
# Extract name from filename
name_part = ref_name.split('_Teasing')[0].replace('_Single_Courtesan_' + args.tier, '').replace('_', ' ')
identity = identity_map.get(name_part.replace(' ', '_'), {}).get('identity', '')
eye = extract_eye(identity) or 'eyes'
pose = pose_variants[tag]
return f"""
Single adult, character name reference: {name_part}.
Identity: {identity}.
Eye color: {eye}. Eye color must match the reference exactly.
Use ONLY the provided reference image as the exact outfit source.
Keep the same garment, colors, fabrics, patterns, and accessory placement; pattern placement must match the reference.
Garments remain intact with no tears, rips, holes, fraying, or cuts.
Teasing More stage (Topless-Framed): both shoulders bare; garment lowered to expose chest fully; nipples visible and unobstructed; garment still worn high framing the chest; no nudity below the waist.
Pose: {pose}.
Same setting as reference image, consistent architecture and lighting.
Keep the same face/likeness as the reference; preserve facial marks exactly; no airbrushing.
Smiling warmly with inviting expression and direct eye contact.
Cinematic 16:9, photorealistic, warm intimate lighting.
No facial scars or injuries.
{anti_modern}
{NEGATIVE_TEXT}
""".strip()
def build_prompt_pair(ref_name, tag, identity_map):
# Parse pair names from filename
parts = ref_name.split('_')
if ref_name.startswith('DoubleTwin'):
name1 = f"{parts[1]} {parts[2]}"
name2 = f"{parts[3]} {parts[4]}"
twin_clause = "They are identical twins with the same face, same features, same marks."
id1 = identity_map.get(f"{parts[1]}_{parts[2]}", {}).get('identity', '')
id_clause = f"Identity for both: {id1}."
elif ref_name.startswith('Double_'):
name1 = f"{parts[1]} {parts[2]}"
name2 = f"{parts[3]} {parts[4]}"
twin_clause = "They have distinct faces and clearly different facial features."
id1 = identity_map.get(f"{parts[1]}_{parts[2]}", {}).get('identity', '')
id2 = identity_map.get(f"{parts[3]}_{parts[4]}", {}).get('identity', '')
id_clause = f"Identity {name1}: {id1}. Identity {name2}: {id2}."
elif ref_name.startswith('Triple'):
name1 = f"{parts[1]} {parts[2]}"
name2 = f"{parts[3]} {parts[4]}"
name3 = f"{parts[5]} {parts[6]}"
twin_clause = "They have distinct faces and clearly different facial features."
id1 = identity_map.get(f"{parts[1]}_{parts[2]}", {}).get('identity', '')
id2 = identity_map.get(f"{parts[3]}_{parts[4]}", {}).get('identity', '')
id3 = identity_map.get(f"{parts[5]}_{parts[6]}", {}).get('identity', '')
id_clause = f"Identity {name1}: {id1}. Identity {name2}: {id2}. Identity {name3}: {id3}."
pose = pose_variants[tag]
return f"""
Multiple adult women, character name references: {name1}, {name2}{', ' + name3 if 'name3' in locals() else ''}.
{twin_clause}
{id_clause}
Use ONLY the provided reference image as the exact outfit source.
Keep the same garment, colors, fabrics, patterns, and accessory placement; pattern placement must match the reference.
Garments remain intact with no tears, rips, holes, fraying, or cuts.
Teasing More stage (Topless-Framed): both shoulders bare on each; garments lowered to expose chests fully; nipples visible and unobstructed with anatomically correct lateral placement; garments still worn high framing each chest; no nudity below the waist.
Pose: {pose}.
Same setting as reference image, consistent architecture and lighting.
Keep the same face/likeness as the reference; preserve facial marks exactly; no airbrushing.
Smiling warmly with inviting expression and direct eye contact.
Cinematic 16:9, photorealistic, warm intimate lighting.
No facial scars or injuries.
{anti_modern}
{NEGATIVE_TEXT}
""".strip()
def render_job(ref_path, tag, runhex, identity_map):
ref_name = ref_path.stem.replace('_Teasing__' + ref_path.stem.split('__')[-1], '')
out_file = f"{ref_name}_TeasingMore_{tag}__{runhex}.jpg"
out_path = out_dir / out_file
if out_path.exists():
return {"status": "skip", "output": str(out_path)}
# Determine if single or pair/triple
if any(ref_name.startswith(p) for p in ['Double', 'Triple']):
prompt = build_prompt_pair(ref_name, tag, identity_map)
else:
prompt = build_prompt_single(ref_name, tag, identity_map)
payload = {
"model": "grok-imagine-image",
"prompt": prompt,
"image": {"url": data_url(ref_path)},
"aspect_ratio": "16:9",
}
try:
r = requests.post(API_URL, headers=headers, data=json.dumps(payload), timeout=90)
if r.status_code == 200:
url = r.json()["data"][0]["url"]
subprocess.run(["curl", "-sS", "-L", url, "-o", str(out_path)], check=True, timeout=60)
return {"status": "success", "output": str(out_path)}
else:
return {"status": "failed", "error": f"HTTP {r.status_code}: {r.text[:200]}"}
except Exception as e:
return {"status": "exception", "error": str(e)}
# Build job list
runhex = os.urandom(4).hex()
print(f"{'='*60}")
print(f"{args.tier} Teasing More A-E (runhex={runhex})")
print(f"{'='*60}\n")
teasing_refs = list(ref_dir.glob('*_Teasing__*.jpg'))
teasing_more_exist = {f.stem.split('_TeasingMore')[0] for f in out_dir.glob('*_TeasingMore__*.jpg')}
jobs = []
for ref in teasing_refs:
ref_base = ref.stem.replace('_Teasing__' + ref.stem.split('__')[-1], '')
if ref_base in teasing_more_exist:
continue # Already have Teasing More
for tag in ['A', 'B', 'C', 'D', 'E']:
jobs.append((ref, tag, runhex, identity_by_name))
print(f"Total jobs: {len(jobs)}\n")
success = 0
failed = 0
skip = 0
with ThreadPoolExecutor(max_workers=args.workers) as ex:
futures = {ex.submit(render_job, *j): j for j in jobs}
for future in as_completed(futures):
try:
result = future.result()
if result["status"] == "success":
success += 1
if success % 10 == 0:
print(f"PROGRESS: ok={success} fail={failed} skip={skip}")
elif result["status"] == "skip":
skip += 1
else:
failed += 1
if failed <= 5:
print(f"FAIL: {result.get('error', '?')[:100]}")
except Exception as e:
failed += 1
print(f"\n{'='*60}")
print(f"DONE: ok={success} fail={failed} skip={skip}")
print(f"{'='*60}")
if __name__ == "__main__":
main()