env backup 2026-11-08 from 4090: root-scripts/run_edit_r2.py
Browse files- root-scripts/run_edit_r2.py +50 -0
root-scripts/run_edit_r2.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Machine-side driver R2: generic B1 edit (single or dual image) for EP1 V2 frame fixes.
|
| 3 |
+
Job fields: name, src (file in IN), image2 (optional absolute path or file in IN), prompt, seed.
|
| 4 |
+
Mirrors run_facefix2.py validated params: steps 40, cfg 1.0, euler/simple, denoise 1.0, resolution 1280.
|
| 5 |
+
"""
|
| 6 |
+
import json, sys, time
|
| 7 |
+
sys.path.insert(0, "/workspace/projects/qwen21-nsfw-pose/scripts")
|
| 8 |
+
from qwen_pose_test import run, upload_image
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
IN = Path("/workspace/facefix_r2_in")
|
| 12 |
+
OUT = Path("/workspace/facefix_r2_out"); OUT.mkdir(exist_ok=True)
|
| 13 |
+
|
| 14 |
+
def main():
|
| 15 |
+
jobs = json.load(open(sys.argv[1]))
|
| 16 |
+
cache = {}
|
| 17 |
+
def up(p):
|
| 18 |
+
p = str(p)
|
| 19 |
+
if p not in cache:
|
| 20 |
+
cache[p] = upload_image(Path(p))
|
| 21 |
+
print("uploaded", p, "->", cache[p], flush=True)
|
| 22 |
+
return cache[p]
|
| 23 |
+
for j in jobs:
|
| 24 |
+
name = j["name"]
|
| 25 |
+
out = OUT / f"{name}.png"
|
| 26 |
+
if out.exists():
|
| 27 |
+
print("skip exists", name, flush=True); continue
|
| 28 |
+
src = IN / j["src"]
|
| 29 |
+
t0 = time.time()
|
| 30 |
+
try:
|
| 31 |
+
cfg = {
|
| 32 |
+
"mode": "edit", "name": f"fixr2/{name}",
|
| 33 |
+
"image_name": up(src), "source": str(src),
|
| 34 |
+
"prompt": j["prompt"], "negative": "",
|
| 35 |
+
"seed": j["seed"], "steps": 40, "cfg": 1.0,
|
| 36 |
+
"sampler": "euler", "scheduler": "simple", "denoise": 1.0,
|
| 37 |
+
"resolution": 1280, "out": str(out),
|
| 38 |
+
}
|
| 39 |
+
if j.get("image2"):
|
| 40 |
+
p2 = j["image2"]
|
| 41 |
+
p2 = p2 if p2.startswith("/") else str(IN / p2)
|
| 42 |
+
cfg["image2_name"] = up(p2); cfg["source2"] = p2
|
| 43 |
+
res = run(cfg)
|
| 44 |
+
print(f"done {name} ok={res['ok']} secs={res.get('seconds')} wall={round(time.time()-t0)}", flush=True)
|
| 45 |
+
except Exception as e:
|
| 46 |
+
print(f"FAIL {name}: {type(e).__name__} {str(e)[:300]}", flush=True)
|
| 47 |
+
print("ALL JOBS DONE", flush=True)
|
| 48 |
+
|
| 49 |
+
if __name__ == "__main__":
|
| 50 |
+
main()
|