-
Notifications
You must be signed in to change notification settings - Fork 8
Node Overview
At a high level nodes are structured into two main sections:
- the class name followed by
- a definiton for the input types
- core variables for the RETURN_TYPE, RETURN_NAME, FUNCTION and CATEGORY
- definitions for the main function and any sub-functions local to the class
This section configures:
- the class name
- the inputs and outups
- the name of the main function
- the location the node will appear in the node menu
Example:
class CR_ApplyControlNet:
@classmethod
def INPUT_TYPES(s):
return {"required": {"conditioning": ("CONDITIONING", ),
"control_net": ("CONTROL_NET", ),
"image": ("IMAGE", ),
"switch": (["On","Off"],),
"strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01})
}
}
RETURN_TYPES = ("CONDITIONING", "STRING", )
RETURN_NAMES = ("CONDITIONING", "show_help", )
FUNCTION = "apply_controlnet"
CATEGORY = "Comfyroll/ControlNet"
Some nodes are more complex than this, but this structure is common to most nodes.
Class names usually use the Upper Camel Case or Pascal Case naming convention.
https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/capitalization-conventions
Example class names:
- CR_LatentInputSwitch
- LoadImageFromUrl_
- UnsamplerHookProvider
- WAS_Mask_Dilate_Region
- RgthreeLoraLoaderStack
The INPUT_TYPES definition must be preceeded by @classmethod
.
There are three types of inputs type:
- required
- optional
- hidden
Required inputs must contain a valid value for the workflow to complete successully.
Optional inputs do not require any input. They can be left blank without interrupting the workflow execution.
Hidden data types do not show as inputs on the nodes. Examples include inputs for the Prompt.
Example:
RETURN_TYPES = ("LATENT",)
RETURN_TYPES must match the return statement in the main function.
Example:
RETURN_NAMES = ("latent",)
RETURN_NAMES are required if the labels on the outputs are different to the output data types. If the labels are the same then this variable is not required.
Example:
CATEGORY = "Comfyroll/ControlNet"
The second part of the node class comprises the main function plus any sub-functions local to the class.
This second is WIP.
Example:
return (latent_out, )
- the main function may use multiple returns but only one will execute
- in most cases this should be a tuple in the format