Developing Custom Nodes in ComfyUI - Part 1
While working on various AI projects, I often found myself thinking, "I wish there was a specific node for this." Relying on workarounds can be exhausting over time. So, I decided to take matters into my own hands and build my own nodes. Since these are functions I’ll use frequently, investing a little time to build them now will save a massive amount of effort later.
ComfyUI Manager
Most users are accustomed to downloading new nodes through ComfyUI Manager by clicking on Extensions. ComfyUI Manager is a very convenient tool that allows users to search for and install nodes with just a few clicks.
custom_nodes Folder
Even without the Manager, installing nodes manually is quite simple. If you navigate to the comfyui/custom_nodes directory, you can see every extension you've installed. This is exactly where we will create our own custom workspace.
Video-Frame-Extractor
My goal is to build a node that extracts specific frames from a video and returns them as images. I started by creating a new folder within custom_nodes named video-frame-extract.
To make the node functional, we only need two essential files:
__init__.py: Required for ComfyUI to recognize the folder as a valid node.frame_extract.py: This is where our actual logic will reside.
For coding, I highly recommend using a proper code editor like Visual Studio Code (VS Code). It makes managing Python scripts much easier.
Wrapping
In this post, we looked into what custom nodes are and what we were doing with extensions.
What we've done so far:
- Explored where the custom nodes actually live (
custom_nodesfolder). - Created a dedicated space for our very first project.
- Set up the skeleton with
__init__.pyand our script file.
Next
Preparation is complete. In the next post, I will explain the nodes I wrote myself. I will also explain in detail how to extract frames and how to ensure the nodes are actually displayed in the ComfyUI menu.
Comments
Post a Comment