import json, sys, threading, time, os sys.path.insert(0, '/workspaces/studio') import horde items = json.load(open('/workspaces/studio/items.json')) only = sys.argv[1].split(',') seed = int(sys.argv[2]) os.makedirs('/tmp/work/zi', exist_ok=True) def job(it): out = f"/tmp/work/zi/{it['id']}_{seed}.webp" for a in range(4): try: body_pp = True horde.gen_pp(it['prompt'] + ", shot on iPhone, vertical photo, authentic, sharp details", out, seed) return except Exception as e: print('err', it['id'], e, getattr(e, 'read', lambda: b'')()[:200], flush=True); time.sleep(20) ts = [] for it in items: if it['id'] in only: t = threading.Thread(target=job, args=(it,)); t.start(); ts.append(t); time.sleep(2) for t in ts: t.join()