Chaoses-Ib/ComfyScript
A Python frontend and library for ComfyUI
What it solves
ComfyScript provides a Python-based interface for ComfyUI, replacing the traditional graph-based node GUI with readable Python code. This solves the difficulty of comparing, reusing, and versioning complex workflows, and enables the use of standard programming constructs like loops and custom functions that are impractical in a visual editor.
How it works
It acts as a frontend and library that can either run locally or connect to a remote ComfyUI server. It includes a transpiler that converts existing ComfyUI JSON workflows into Python scripts and a runtime that allows these scripts to execute ComfyUI nodes as if they were Python functions. It also generates type stubs to provide autocomplete and type checking in editors like VS Code.
Who it’s for
- Developers and Researchers: Who want to use ComfyUI nodes as a function library for ML research or integrate them into larger Python projects.
- Power Users: Who prefer coding over visual node graphs or need to generate massive workflows programmatically using loops.
- LLM Developers: Who want to train LLMs to generate workflows, as LLMs typically handle Python code better than complex JSON structures.
Highlights
- Workflow Transpilation: Automatically converts ComfyUI web UI workflows into human-readable Python code.
- Programmatic Control: Allows mixing Python logic (loops, conditionals) with ComfyUI nodes.
- Developer Experience: Provides type stubs and Python enumerations for checkpoints and embeddings to enable IDE autocomplete.
- Flexible Execution: Supports both local and remote server execution, including asynchronous task queuing.
- UI Integration: Compatible with ipywidgets and Solara for creating custom Python-based interfaces for image generation.
Related
- Project
- Project
- Project
- Project
- Project