ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

Add a Gradio websocket API interface example for running api workflows with previews/progress/interrupt

Open RandomGitUser321 opened this issue 1 year ago • 2 comments

A simple interface demo showing how you can link Gradio and ComfyUI together. I know there are obviously alternatives like Forge, but being able to make complex custom api workflows and then run them from a simple UI is always great, plus Gradio works really well from phones and tablets. I left a lot of notes to help explain things. I'm sure it's not the prettiest coding, but it works and handles most of the edge cases that I could think of.

Also features: Interrupting, progress and previews.

Working previews: image Final image: image

I personally recommend using the following to handle loading workflows, instead of having the mess within the code:

with open("/path/to/workflow.json", "r", encoding="utf-8") as f:
    prompt = json.load(f)

RandomGitUser321 avatar Sep 22 '24 12:09 RandomGitUser321