ComfyUI-serverless #1620
irakli-ff
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Its kinda offtopic but you might like to have a look here, its not really compfy but its serverless and able to run native comfy nodes... https://github.com/XmYx/ainodes-engine |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
See repo: https://github.com/fidecastro/ComfyUI-serverless
A connector to use ComfyUI in serverless deployments
ComfyUI is incredibly flexible and fast; it is the perfect tool launch new workflows in serverless deployments. Unfortunately, there isn't a lot on API documentation and the examples that have been offered so far don't deal with some important issues (for example: good ways to pass images to Comfy, generalized handling of API json files,
Using the websocket endpoint that Comfy offers, I created a very simple way to generate images from Comfy via code. With the ComfyConnector class, you may:
Automatically start Comfy webserver (no need to python3 main.py)
Easily edit the API json file using the replace_key_value method, regardless of how complex/spaghettized your workflow may be (no need to hardcode your inputs based on each workflow; just tell the function what parameter to look for and it will change it for you)
Send to Comfy the API json file containing the workflow topology and editable parameters, and receive back the generated images as an image list object
Send to Comfy images and receive back an image list object for use in img2img/controlnet workflows
Automatic discovery of the outputs in a JSON file via the find_output_node method
Kill main.py after generation using the kill_api method
With this repository, generating images with Comfy takes two lines of code:
prompt = json.load(open('workflow_api.json')) # loads the workflow_api.json file as exported by ComfyUI dev mode
images = api_singleton.generate_images(prompt) # sends the json file and receives back the generated images
This repository makes it very simple to connect ComfyUI with handling functions. It is a drop-in addition to the repository and only interacts with the existing codebase as it extends the utility of its already-functioning websocket API service.
(IMPORTANT: Your workflow MUST CONTAIN one, and only one, SaveImage node for the connector to work, since this will be deemed your output node and will be used by the connector to fetch any generated images.)
Beta Was this translation helpful? Give feedback.
All reactions