#!/usr/bin/env python3 """Machine-side driver R3B: B1 edits (dual-image identity anchor / single-image fix) for EP01 R3 B-stage. Mirrors run_edit_r2.py validated params: steps 40, cfg 1.0, euler/simple, denoise 1.0, resolution 1280. Job fields: name, src (file in IN), char (optional: kf/jx -> dual-image anchor), prompt, seed. """ import json, sys, time sys.path.insert(0, "/workspace/projects/qwen21-nsfw-pose/scripts") from qwen_pose_test import run, upload_image from pathlib import Path IN = Path("/workspace/facefix_r3b_in") OUT = Path("/workspace/facefix_r3b_out"); OUT.mkdir(exist_ok=True) ANCHORS = {"kf": "/workspace/facefix_in/anchor_kf.png", "jx": "/workspace/facefix_in/anchor_jx.png"} def main(): jobs = json.load(open(sys.argv[1])) cache = {} def up(p): p = str(p) if p not in cache: cache[p] = upload_image(Path(p)) print("uploaded", p, "->", cache[p], flush=True) return cache[p] for j in jobs: name = j["name"] out = OUT / f"{name}.png" if out.exists(): print("skip exists", name, flush=True); continue t0 = time.time() try: cfg = { "mode": "edit", "name": f"r3b/{name}", "image_name": up(IN / j["src"]), "source": str(IN / j["src"]), "prompt": j["prompt"], "negative": "", "seed": j["seed"], "steps": 40, "cfg": 1.0, "sampler": "euler", "scheduler": "simple", "denoise": 1.0, "resolution": 1280, "out": str(out), } if j.get("char"): ap = ANCHORS[j["char"]] cfg["image2_name"] = up(ap); cfg["source2"] = ap res = run(cfg) print(f"done {name} ok={res['ok']} secs={res.get('seconds')} wall={round(time.time()-t0)}", flush=True) except Exception as e: print(f"FAIL {name}: {type(e).__name__} {str(e)[:300]}", flush=True) print("ALL JOBS DONE", flush=True) if __name__ == "__main__": main()