The ComfyUI-to-Python-Extension lets you translates
ComfyUI workflows into executable
Python code. Designed to bridge the gap between ComfyUI's visual interface and
Python's programming environment, this script facilitates the seamless
transition from design to code execution. Whether you're a data scientist, a
software developer, or an AI enthusiast, this tool streamlines the process of
implementing ComfyUI workflows in Python.
-
Navigate to the
ComfyUI-to-Python-Extensionfolder and install requirementspip install -r requirements.txt
-
Launch ComfyUI, click the gear icon over
Queue Prompt, then checkEnable Dev mode Options. THE SCRIPT WILL NOT WORK IF YOU DO NOT ENABLE THIS OPTION!
-
Load up your favorite workflows, then click the newly enabled
Save (API Format)button under Queue Prompt -
Move the downloaded .json workflow file to your
ComfyUI/ComfyUI-to-Python-Extensionfolder -
Run the script:
python src/comfyui_to_python.py
answer the prompts for input and output file:
Using xformers cross attention > ComfyUI worflow file (.json): workflow_api.json > Output to (.py): generated_code.py -
After running
comfyui_to_python.py, a new .py file will be created in the current working directory. If you made no changes, look forworkflow_api.py. -
Now you can execute the newly created .py file to generate images without launching a server:
python generated_code.py
