ComfyUI-to-Python-Extension
The ComfyUI-to-Python-Extension
is an innovative tool designed to convert visual workflows from ComfyUI into executable Python code. This tool serves as a bridge between ComfyUI's user-friendly graphical interface and the extensive capabilities of Python.
Purpose and Functionality
ComfyUI provides a visual platform for creating complex workflows without the need for extensive programming skills. However, there are times when users might want to execute these workflows directly in a Python environment, taking full advantage of Python's extensive libraries and flexibility. The ComfyUI-to-Python-Extension
makes this possible by translating these visual workflows into Python scripts.
Conversion Process
Users can seamlessly convert their ComfyUI-created workflows into Python code. For example, what starts as an intuitive visual interface design in ComfyUI can be transformed into Python code, complete with library imports and method definitions, ready to run in any Python environment.
Key Features
- Streamlined Transition: Facilitates the transition from design in ComfyUI to code execution in Python, saving time and reducing manual coding efforts.
- Flexible Implementation: Users can create experiments, develop pipelines, and generate large batches of images directly from a script.
- Extendable Architecture: Once the foundational workflow is set in ComfyUI, developers can easily expand or iterate on it in Python.
Release Highlights
- Version 1.3.0: Users can now generate a .py file directly from the ComfyUI Web App interface, enhancing the ease of use.
- Version 1.2.1: Introduced the capability to dynamically change parameters in the
comfyui_to_python.py
script via CLI arguments and fixed issues related to nodes acceptingkwargs
. - Version 1.2.0: Updated to match the latest changes in ComfyUI's functionalities.
- Version 1.0.0: Added support for custom nodes, allowing greater flexibility in workflow execution.
Installation Steps
-
Navigate to Directory: Go to your
ComfyUI/custom_nodes
folder. -
Clone the Repository: Use the command below to clone the extension:
git clone https://github.com/pydn/ComfyUI-to-Python-Extension.git
After installation, your
ComfyUI
directory will include the newly added extension folder.
Web App Utilization
- Launch ComfyUI: Start the application on your system.
- Load and Save Workflow: Select your workflow and choose
Save As Script
. - File Management: Save the generated .py file and move it to your
ComfyUI
directory to execute without needing server initialization.
Command Line Interface Usage
- Install Requirements: Enter the
ComfyUI-to-Python-Extension
folder and run:pip install -r requirements.txt
- Enable Developer Options: In ComfyUI, activate Developer Mode under Queue Prompt.
- Load Workflow: Load desired workflows and save them using the
Save (API Format)
function. - Script Execution: Run the script to create a Python file ready for execution:
Optionally, customize input and output filenames with:python comfyui_to_python.py
python comfyui_to_python.py --input_file "workflow_api (2).json" --output_file my_workflow.py --queue_size 100
The ComfyUI-to-Python-Extension
thus provides a robust solution for developers and hobbyists wishing to leverage Python's power while benefiting from the visual approach of ComfyUI, making it an indispensable tool for efficient workflow management and execution.