ComfyUI

Extending ComfyUI with Python

Learn how to automate your workflows with Python

Shawn @ Prompting Pixels

What You'll Learn

Learn how to automate ComfyUI workflows using Python scripts that can batch process images, send data via API, and integrate with other Python tools.

Video Walkthrough

Prefer watching to reading? Follow along with a step-by-step video guide.

Extending ComfyUI with Python

ComfyUI’s power can be greatly enhanced when combined with Python. Here’s how to set it up:

  1. Install the ComfyUI tooling nodes custom node.
  2. Enable dev mode in ComfyUI settings.
  3. Set Node ID badge mode to “show all” in Light Graph settings.

Workflow Notes:

The workflow itself doesn’t really matter. All that does is the “Load Image (Base64)” (if performing an image-to-image task) and the “Send Image (WebSocket)” as an output node.

Make sure to notate the Node ID if using the Load Image (Base64) node and also export the workflow as an API file.

Python Integration:

  1. Create a directory with your input image, main.py file, and workflow file.
  2. Main.py will load the workflow, encode the input image to Base64, and send/receive the data to the ComfyUI server.
  3. Be sure to update the server IP address and Load Image node ID in the Python script.

This setup allows for batch processing, automation, and integration with other Python tools, greatly expanding ComfyUI’s capabilities.

Want More AI Image Tutorials?

Get the best AI image tutorials and tool reviews—no spam, just 1 or 2 helpful emails a month.

Continue Learning

More ComfyUI Tutorials

Explore additional tutorials in the ComfyUI category.

View All Tutorials