Download tools/run_workflow.py from BennyDaBall/Qwen-Image-2.1-NVFP4: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/BennyDaBall/Qwen-Image-2.1-NVFP4/resolve/main/tools/run_workflow.py
- Command line
-
hf download hf://BennyDaBall/Qwen-Image-2.1-NVFP4/tools/run_workflow.py
-
curl -L -o run_workflow.py https://huggingface.co/BennyDaBall/Qwen-Image-2.1-NVFP4/resolve/main/tools/run_workflow.py
1.1 kB
| """Run an included API workflow against a local ComfyUI server.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import time | |
| from urllib.request import Request, urlopen | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('workflow', type=Path) | |
| parser.add_argument('--server', default='http://127.0.0.1:8188') | |
| args = parser.parse_args() | |
| graph = json.loads(args.workflow.read_text(encoding='utf-8')) | |
| request = Request(args.server + '/prompt', data=json.dumps({'prompt':graph}).encode(), headers={'Content-Type':'application/json'}) | |
| with urlopen(request, timeout=30) as response: | |
| prompt_id = json.load(response)['prompt_id'] | |
| print('Queued:',prompt_id,flush=True) | |
| while True: | |
| with urlopen(args.server + '/history/' + prompt_id, timeout=30) as response: | |
| history = json.load(response).get(prompt_id) | |
| if history: | |
| print(json.dumps(history['status'],indent=2)) | |
| print(json.dumps(history['outputs'],indent=2)) | |
| if history['status']['status_str'] != 'success': | |
| raise SystemExit(1) | |
| break | |
| time.sleep(0.5) | |