Extensions/ComfyUI-CustomNodes-Template
ComfyUI Extension

ComfyUI-CustomNodes-Template

ComfyUI CustomNode Template

By jhj0517·Created 2 years ago·Updated 2 years ago· 44
jhj0517/ComfyUI-CustomNodes-Template
Nodes4
On cloudLocal install
CategoryCustomNodesTemplate
Stars44
Updated2 years ago
Readme

ComfyUI CustomNode Template

This is the ComfyUI custom node template repository that anyone can use to create their own custom nodes.

Directory Structure

Project-Name/
├── .github/                # GA workflow for publishing the ComfyUI registry 
├── workflows/              # Example workflows for your custom node
├── modules/                # Your own modules for the custom node
├── .gitignore              # gitignore file 
├── __init__.py             # Map your custom node display names here 
├── nodes.py                # Your custom node classes  
├── README.md               # README file
├── pyproject.toml          # Metadata file for the ComfyUI registry
└── requirements.txt        # Project dependencies 

Custom Node Files

nodes.py

This file is where your actual custom node classes are defined. The class has specific methods that are called by the ComfyUI engine. There're some basic custom nodes for the example with some comments, you can modify them as you need. For detailed information on how to create custom nodes, please refer to the ComfyUI official documentation:

  • https://docs.comfy.org/essentials/custom_node_walkthrough.

init.py

You can map your custom node display names here. It will be used when users search for your custom node in the ComfyUI.

pyproject.toml

This file is used to publish your custom node to the ComfyUI registry. If you want to publish your custom node to the ComfyUI registry, you need to modify this file.

If you wonder what ComfyUI registry is, please read:

  • https://docs.comfy.org/registry/overview#why-use-the-registry

requirements.txt

This file contains the dependencies needed for your custom node. torch is already installed in the ComfyUI, so you only need to add "extra" dependencies here.

workflows/example-1.json

This is optional, but it is recommended to put your ComfyUI workflow json file inside your project so users can easily understand how to use your custom node.

Github Actions

publish-comfyui-registry.yml

When you push into the master branch, this workflow will be triggered and publish your custom node to the ComfyUI registry, using your pyproject.toml. You have to register your "REGISTRY_ACCESS_TOKEN" in the Github Action Secrets which you can get from:

  • https://docs.comfy.org/registry/publishing#create-an-api-key-for-publishing

After generating the repository from this template, uncomment the push to enable the workflow with auto trigger:

https://github.com/jhj0517/ComfyUI-CustomNodes-Template/blob/6ae10a1d161933c5e3cff432e1c8bbc9396be954/.github/workflows/publish-comfyui-registry.yml#L4-L10

Github Issue & PR templates

There are some basic templates for the Github issues & PR. You can edit them or add more to fit your project's needs.

How to Strat Using Template

Click "Use this template" -> "Create a new repository", then you can create your own custom node from there.

image

The custom node installation guide below can usually be used for any custom node, you can use it in your README by modifying the repository name and URL.

Installation

  1. git clone repository into ComfyUI\custom_nodes\
git clone https://github.com/replace-this-with-your-github-repository-url.git
  1. Go to ComfyUI\custom_nodes\ComfyUI-Your-CustomNode-Name and run
pip install -r requirements.txt

If you are using the portable version of ComfyUI, do this:

python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\ComfyUI-Your-CustomNode-Name\requirements.txt