Spaces:
Running
Running
Download source/studio/horde_batch.py from Ethscriptions/eths: direct link, hf CLI and curl.
- Browser
- Download file 806 Bytes
-
https://huggingface.co/spaces/Ethscriptions/eths/resolve/main/source/studio/horde_batch.py
- Command line
-
hf download hf://spaces/Ethscriptions/eths/source/studio/horde_batch.py
-
curl -L -o horde_batch.py https://huggingface.co/spaces/Ethscriptions/eths/resolve/main/source/studio/horde_batch.py
806 Bytes
| 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() | |