File size: 1,993 Bytes
8518eee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
"""Machine-side driver R2: generic B1 edit (single or dual image) for EP1 V2 frame fixes.
Job fields: name, src (file in IN), image2 (optional absolute path or file in IN), prompt, seed.
Mirrors run_facefix2.py validated params: steps 40, cfg 1.0, euler/simple, denoise 1.0, resolution 1280.
"""
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_r2_in")
OUT = Path("/workspace/facefix_r2_out"); OUT.mkdir(exist_ok=True)

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
        src = IN / j["src"]
        t0 = time.time()
        try:
            cfg = {
                "mode": "edit", "name": f"fixr2/{name}",
                "image_name": up(src), "source": str(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("image2"):
                p2 = j["image2"]
                p2 = p2 if p2.startswith("/") else str(IN / p2)
                cfg["image2_name"] = up(p2); cfg["source2"] = p2
            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()