Utilities for working with the ComfyUI API.
Project description
ComfyUI utils
This package provides simple utils for:
- Parsing out prompt arguments, e.g. "a beautiful forest $num_steps=12"
- Running a workflow in parsed API format against a ComfyUI endpoint, with callbacks for specified events.
It's designed primarily for developing casual chatbots (e.g. a Discord bot) where users can adjust certain parameters and receive live progress updates.
Limitations:
- Only integer arguments are currently supported in addition to the prompt itself. The plan is to add at least floats and strings.
- Only one output from the workflow is supported.
Install
pip install comfyui_utils
Example.
To test the library with a sample SDXL workflow, clone this repository and run the following (replacing the address). Make sure your ComfyUI has sd_xl_base_1.0.safetensors
and sd_xl_refiner_1.0.safetensors
installed (or replace the workflow).
comfy_ui_example_e2e\
--address='192.168.0.10:11010'\
--prompt='a smiling potato $base_steps=8$refiner_steps=3'\
--output='./potato.png'
The single quotes are important so your shell doesn't try to parse the $
's. Expected output:
Queuing workflow.
Queue position: #0
Base...
Base: 1/8
Base: 2/8
Base: 3/8
Base: 4/8
Base: 5/8
Base: 6/8
Base: 7/8
Base: 8/8
Refiner...
Refiner: 1/3
Refiner: 2/3
Refiner: 3/3
Decoding...
Saving image on backend...
Result (cached: no):
{'images': [{'filename': 'ComfyUI_00101_.png', 'subfolder': '', 'type': 'output'}]}
The file will be saved in the root directory.
Use your own workflow.
After finalizing the workflow, use the "Save (API format)" button to store the workflow. Then, edit the PromptConfig
in the script to reflect the arguments you wish to make available, and ensure the prompt has them replaced after parsing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for comfyui_utils-0.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96458ac8377d158bcf5dfaf255058e8ff49cbe9197ace7f44699ca1c4a652663 |
|
MD5 | 266e7e05f2c9355f0b4acad9224e3d69 |
|
BLAKE2b-256 | 65b832feeb0e8ce3e03aa5ad0a98c12487b18bdc5b5a3be369cdb11223c2e54e |