Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

ssitu/ComfyUI_NestedNodeBuilder

Repository files navigation

Archived (1/11/2024)

An identical feature now exists in ComfyUI. Additionally, this extension is largely broken with the recent versions of the codebase, so please use the built-in feature for group nodes.

Original Description Below

ComfyUI_NestedNodeBuilder

Adds a feature for the default interface in ComfyUI that allows for nesting of other nodes for better organization and simplification of repetitive patterns in workflows.

Disclaimer

This is a prototype and will likely have many problems. This will probably be obsolete once subgraphs are implemented within ComfyUI. To be safe, save your workflow before nesting any nodes. How nested nodes are saved are subject to change and saved nodes may become unusable in the future.

Installation

Enter the following command from the commandline starting in ComfyUI/custom_nodes/

git clone https://github.com/ssitu/ComfyUI_NestedNodeBuilder

Usage

Demo:

NestedNodeBuilderDemo

Instructions:

1. Selecting the nodes to nest Select multiple nodes by using Ctrl/Shift + left/right click on the desired nodes to nest. You can also use Ctrl + left click + drag to highlight nodes.
2. Nesting the selected nodes After making a selection, right click on any of the selected nodes and select Nest Selected Nodes and choose a name that won't conflict with any other existing node. The selected nodes will be replaced with a new node that contains the selected nodes. You can also unnest the new node by right clicking on the node and clicking Unnest. The selected nodes may also be converted to an already existing nested node using the Convert selected to Nested Node: <name> option that appears if the selected nodes have a similar structure.
3. Creating a nested node from the node menu Nested nodes are saved and can be created again from the node menu that appears when you right click on the canvas under the Nested Nodes category.
4. Where are nested nodes saved? You can find them under ComfyUI/custom_nodes/ComfyUI_NestedNodeBuilder/nested_nodes/. This directory can be changed by editing the nested_nodes_path entry in the config.yaml. The nested nodes are stored as .json files. The names of the nested nodes may be changed by editing their .json files. The changes made to the directory are registered after refreshing the web UI.

How it works

The nodes that are nested are stored in the properties of the nested node. Before the prompt is calculated, the nested node is replaced with the nodes that it stored. After the prompt is calculated, the nodes are nested again. Depending on performance, this may cause a quick flash of what the workflow looks like after the nodes are unnested when queueing a prompt. This seemed to be the approach that was the least intrusive on the ComfyUI codebase.

Known Problems

  • Nested nodes cannot be nested themselves.
  • When converting a seed widget to input and connecting it to a primitive node, the prompt will ignore the control_after_generate widget of the primitive node and yield to the underlying control_after_generate widget of the respective node. Can be solved by changing the values to "fixed" before nesting.
  • Can't really nest output nodes such as preview image and save image nodes. It works, but it won't display the image.

Feel free to open an issue if you find any other problems.

Credits

Inspired by this repo by ltdrdata, check it out if you want something more robust and flexible.

About

Adds a feature to ComfyUI that lets you nest nodes under a new node for better organization and simplification of repetitive patterns in workflows.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published