Name | comfy-executors JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-11-08 09:48:05 |
maintainer | None |
docs_url | None |
author | Kristian Klemon |
requires_python | <4.0,>=3.10 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
comfy-executors
===============
Run ComfyUI workflows conveniently on different execution backends, including local ComfyUI servers and serverless execution on [RunPod](https://www.runpod.io/) or [Modal](https://modal.com/). Supports workflow templating, asynchronous execution and transparent batching.
Usage
-----
### Installation
```bash
pip install comfy-executors
```
### Export ComfyUI workflow in API format
ComfyUI has two different workflow formats. The _standard_ format for which contains additional meta data for the UI and a reduced API version which corresponds to the actual execution graph that is send to the backend. Exporting workflows in API format has to be enabled in the developer settings first.
<details>
<summary>API format export instructions</summary>

Afterwards, a separate button for API format export should appear below the normal "Save" button:

</details>
### Prepare workflow for use with comfy-executors
The ComfyUI does not support parameterization of workflows out-of-the-box, i.e. a submitted workflow (in JSON format) will be executed _as it is_. To allow flexible parameterization of workflows, e.g. replacing prompts and the random seeds, `comfy-executors` uses workflow templating via the Jinja templating engine.
To prepare a workflow for use with `comfy-executors`, first append the `.jinja` suffix to the filename, e.g. `workflow.json` becomes `workflow.json.jinja`. The nodes for loading input images and supplying the empty latent image need to be templated to obtain their value from the `input_images_dir` and `batch_size` variables respectively. This should generally as follows:
```json
{
"1": {
"inputs": {
"directory": "{{ input_images_dir }}",
"image_load_cap": 0,
"start_index": 0,
"load_always": false
},
"class_type": "LoadImagesFromDir",
"_meta": {
"title": "Load Reference Images"
}
},
"2": {
"inputs": {
"width": 896,
"height": 1152,
{# Batch sizes need to be templated as it will be determined by comfy-executors #}
"batch_size": {{ batch_size|int }}
},
"class_type": "EmptyLatentImage",
"_meta": {
"title": "Empty Latent Image"
}
},
}
```
Additional variables can, of course, be introduced as well which then have to be passed to the workflow rendering function.
### Submitting a workflow an execution backend
`comfy-executors` supports different execution backends, including local or remote ComfyUI servers and execution on serverless GPUs on [RunPod](https://www.runpod.io/) or [Modal](https://modal.com/).
The `RunpodComfyWorkflowExecutor` class provides functionality to submit a workflow template to RunPod and handle the results.
#### ComfyUI server
```python
from comfy_api_client import create_client
from comfy_executors import ComfyServerWorkflowExecutor, WorkflowTemplate
comfyui_server = "localhost:8188"
workflow_template = WorkflowTemplate.from_file("workflow.json.jinja")
async with ComfyServerWorkflowExecutor.create(
comfyui_server,
batch_size=8,
) as executor:
async for item in executor.submit_workflow_async(
workflow_template=workflow_template,
num_samples=16
):
print(item)
```
#### RunPod
Coming soon.
#### Modal
Coming soon.
A few notes on the example above:
* The executor can be configured to use a certain batch size. The value can also be overwritten by providing a `batch_size` to the `submit_workflow` method.
* A value for `num_samples` can be provided to generate approximately `num_samples / batch_size` batches within a single RunPod job. While multiple jobs could be submitted to achieve the same results, generating multiple batches within a single job will generally make better use of node results caching and thus improve efficiency and latency.
* The result is a list of `WorkflowOutputImage` objects. These provide the output image, the filename as set by ComfyUI and optionally the subfolder to which the image has been saved originally.
Raw data
{
"_id": null,
"home_page": null,
"name": "comfy-executors",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Kristian Klemon",
"author_email": "kristian.klemon@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/cc/e1/7d813888b5d4f896720ba78d9768ead20f44f01d727ec7956b2aefc4a3d2/comfy_executors-0.1.0.tar.gz",
"platform": null,
"description": "comfy-executors\n===============\n\nRun ComfyUI workflows conveniently on different execution backends, including local ComfyUI servers and serverless execution on [RunPod](https://www.runpod.io/) or [Modal](https://modal.com/). Supports workflow templating, asynchronous execution and transparent batching.\n\nUsage\n-----\n\n### Installation\n\n```bash\npip install comfy-executors\n```\n\n### Export ComfyUI workflow in API format\n\nComfyUI has two different workflow formats. The _standard_ format for which contains additional meta data for the UI and a reduced API version which corresponds to the actual execution graph that is send to the backend. Exporting workflows in API format has to be enabled in the developer settings first.\n\n<details>\n <summary>API format export instructions</summary>\n\n\n\nAfterwards, a separate button for API format export should appear below the normal \"Save\" button:\n\n\n</details>\n\n### Prepare workflow for use with comfy-executors\n\nThe ComfyUI does not support parameterization of workflows out-of-the-box, i.e. a submitted workflow (in JSON format) will be executed _as it is_. To allow flexible parameterization of workflows, e.g. replacing prompts and the random seeds, `comfy-executors` uses workflow templating via the Jinja templating engine.\n\nTo prepare a workflow for use with `comfy-executors`, first append the `.jinja` suffix to the filename, e.g. `workflow.json` becomes `workflow.json.jinja`. The nodes for loading input images and supplying the empty latent image need to be templated to obtain their value from the `input_images_dir` and `batch_size` variables respectively. This should generally as follows:\n\n\n```json\n{\n \"1\": {\n \"inputs\": {\n \"directory\": \"{{ input_images_dir }}\",\n \"image_load_cap\": 0,\n \"start_index\": 0,\n \"load_always\": false\n },\n \"class_type\": \"LoadImagesFromDir\",\n \"_meta\": {\n \"title\": \"Load Reference Images\"\n }\n },\n \"2\": {\n \"inputs\": {\n \"width\": 896,\n \"height\": 1152,\n {# Batch sizes need to be templated as it will be determined by comfy-executors #}\n \"batch_size\": {{ batch_size|int }}\n },\n \"class_type\": \"EmptyLatentImage\",\n \"_meta\": {\n \"title\": \"Empty Latent Image\"\n }\n },\n}\n```\n\nAdditional variables can, of course, be introduced as well which then have to be passed to the workflow rendering function.\n\n### Submitting a workflow an execution backend\n\n`comfy-executors` supports different execution backends, including local or remote ComfyUI servers and execution on serverless GPUs on [RunPod](https://www.runpod.io/) or [Modal](https://modal.com/).\n\nThe `RunpodComfyWorkflowExecutor` class provides functionality to submit a workflow template to RunPod and handle the results.\n\n#### ComfyUI server\n\n```python\nfrom comfy_api_client import create_client\nfrom comfy_executors import ComfyServerWorkflowExecutor, WorkflowTemplate\n\ncomfyui_server = \"localhost:8188\"\n\nworkflow_template = WorkflowTemplate.from_file(\"workflow.json.jinja\")\n\nasync with ComfyServerWorkflowExecutor.create(\n comfyui_server,\n batch_size=8,\n) as executor:\n async for item in executor.submit_workflow_async(\n workflow_template=workflow_template,\n num_samples=16\n ):\n print(item)\n```\n\n#### RunPod\n\nComing soon.\n\n#### Modal\n\nComing soon.\n\n\nA few notes on the example above:\n\n* The executor can be configured to use a certain batch size. The value can also be overwritten by providing a `batch_size` to the `submit_workflow` method.\n* A value for `num_samples` can be provided to generate approximately `num_samples / batch_size` batches within a single RunPod job. While multiple jobs could be submitted to achieve the same results, generating multiple batches within a single job will generally make better use of node results caching and thus improve efficiency and latency.\n* The result is a list of `WorkflowOutputImage` objects. These provide the output image, the filename as set by ComfyUI and optionally the subfolder to which the image has been saved originally.\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.1.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c0a2aa1d6b1fc9b04d767cbd0ba9ed1f44bb340343a82608d80a4536cab0cc99",
"md5": "f38facf1da7a6012286ecbd72bd96e70",
"sha256": "c968a3035c294fb47064b57670af412ff747185f97722b923f7b8e1db99fbf5e"
},
"downloads": -1,
"filename": "comfy_executors-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f38facf1da7a6012286ecbd72bd96e70",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 8421,
"upload_time": "2024-11-08T09:48:04",
"upload_time_iso_8601": "2024-11-08T09:48:04.398949Z",
"url": "https://files.pythonhosted.org/packages/c0/a2/aa1d6b1fc9b04d767cbd0ba9ed1f44bb340343a82608d80a4536cab0cc99/comfy_executors-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cce17d813888b5d4f896720ba78d9768ead20f44f01d727ec7956b2aefc4a3d2",
"md5": "2ec9eac96672f7cf259ef449f287f250",
"sha256": "e5d1dc37ce56d701abc8f2fb93cf16c64366fed18cf00b1fbea361562d598529"
},
"downloads": -1,
"filename": "comfy_executors-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "2ec9eac96672f7cf259ef449f287f250",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 8569,
"upload_time": "2024-11-08T09:48:05",
"upload_time_iso_8601": "2024-11-08T09:48:05.641862Z",
"url": "https://files.pythonhosted.org/packages/cc/e1/7d813888b5d4f896720ba78d9768ead20f44f01d727ec7956b2aefc4a3d2/comfy_executors-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-08 09:48:05",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "comfy-executors"
}