14 KiB
D2 Nodes ComfyUI
D2 Nodes ComfyUI is a collection of custom nodes that make ComfyUI slightly more convenient.
It's suitable for those who want to create simple workflows.
Please uninstall any of the following custom nodes if you have previously installed them.
🍅 Nodes
D2 Queue Button
- A button to generate a specified number of images (Batch count)
- Can be moved by dragging the left edge of the palette
Details
- To hide it, configure in the "D2" category of the ComfyUI settings screen
- The number of images can also be specified from the settings screen
- Separate the numbers with commas (,)
D2 Regex Switcher
- Searches input text with regular expressions and outputs matching text
- Can also perform string concatenation
Details
- The main purpose is to switch quality tags for each Checkpoint
- When a matching string is found in the input
text, it outputs the target string and which match it was (starting from 0) - In the image above, it received
ioliPonyMixV4.safetensors, matched the search conditionpony, soscore_9is output - Since it matched the first search condition,
indexoutputs0 - If it doesn't match any conditions,
-1is output - Can also concatenate strings at the front and back
Input
text- Target string for searching
prefix- String to concatenate at the front
suffix- String to concatenate at the back
regex_and_output- List of search strings and output strings
- Enter in the following format:
pre_delim- The character inserted between
prefixandregex_and_outputwhen connecting them Comma:,/Line break: newline /None: no character inserted
- The character inserted between
suf_delim- The character inserted between
suffixandregex_and_outputwhen connecting them
- The character inserted between
Search string 1 (regex can be used)
--
Output string 1
--
Search string 2 (regex can be used)
--
Output string 2
--
--
String to output when nothing matches
Output
combined_text- String combining
prefix+ output string +suffix
- String combining
prefix/suffix- Pass-through from Input
Usage Example
In this example, the matched number (index) is passed to the Text Index Switch of Easy Use for switching.
Since it becomes -1 when there's no match, we use the regular expression .+ that matches all strings as a default output.
D2 Regex Replace
- Replace input text
- Multiple conditions can be specified
Details
- Supports regular expression replacement
- Supports reuse of regex match strings (using \1, \2, etc.)
- Can process target strings in "tag units" or "as a whole"
Input
text- Target string for searching
modeTag: Splitstextby newlines and commas, then replaces individuallyAdvanced: Replaces the entiretextas a whole
regex_and_output- List of search patterns and output strings
- Enter in the format below
- When output string is empty, matched parts will be deleted
- No limit on the number of patterns
Search pattern 1
--
Output string 1
--
Search pattern 2
--
Output string 2
Output
text- Text after replacement processing
Sample
Sample for removing Pony series quality tags.
Mode: Tag
Input text
score_9, score_8_up, (score_7_up, score_6_up:0.8) , rating_explicit, source_anime, BREAK
1girl, swimsuit
Regex Replace
.*(score_|rating_|source_).*
--
--
BREAK
--
Output text
1girl, swimsuit
D2 Prompt SR
- A node that searches and replaces input text and returns it as a list
- A custom node for using Prompt S/R with XY Plot
- Compatible with qq-nodes-comfyui
Details
Input
prompt- Prompt. Can include line breaks
search_txt- Text to search for. Can include multiple words
- Cannot use line breaks
replace- Text for replacement
- Since it's separated by line breaks, it's OK if it contains ","
Output
- LIST
- Outputs replaced text in list format
D2 Multi Output
- A node that outputs general parameters like seed and cfg in list format
Details
Input
typeFLOAT: Floating point number. For CFG, etc.INT: Integer. For steps, etc.STRING: String. For sampler, etc.SEED: Can input seed value with random number generation button
Add Random- Adds random numbers to the input field
- Only displayed when
typeisSEED
D2 Checkpoint Loader
- A Checkpoint Loader that outputs the full path of the model file
Details
Output
model/clip/vae- Same as the conventional CheckpointLoader.
ckpt_name/ckpt_hash/ckpt_fullpath- Checkpoint name, hash, full path.
The implementation mostly uses code from mikey_nodes.
D2 KSampler / D2 KSampler(Advanced)
- A KSampler that can input prompts as STRING
Details
Input
model/clip/vae/ ..etc- Same as standard KSampler
negative/positive- Prompts in STRING format
Output
IMAGE- Image output
positive/negative- Pass-through from Input
D2 Load Image
- Load Image node that can extract prompts from images
- Compatible with images created by StableDiffusion webui A1111 and NovelAI
- A button to open the mask editor has been added
Details
Input
image_path- Used for connection with D2 Folder Image Queue
- Loads the file when an image path is input
Output
IMAGE / MASK- Image and mask
width / height- Image size
positive/negative- Prompts
Note: Depending on the workflow configuration, it may not always be possible to retrieve prompts. For example, prompts cannot be retrieved without a node containing the word "KSampler" (e.g., Tiled KSampler).
D2 Folder Image Queue
- Outputs paths of images in a folder
- Click the
Queue (x - y) imagesbutton to execute queues for the number of images. Don't use the standard Queue button - Very convenient as humans don't need to count the number of images
Details
- This workflow performs img2img using the same prompt for all images in the folder
- A more detailed workflow is introduced in the Sample Workflow chapter
Input
folder- Image folder
extension- Specify filename filter
*.*: All images*.png: PNG format only
start_at- Image number to start processing from
batch_count- How many queues to register per image
Queue (x - y) images- Button to start generation
- x: Number of images
- y:
start_at
Output
image_path- Full path of the image
D2 EmptyImage Alpha
- Added alpha channel (transparency) to EmptyImage
D2 Image Resize
- Simple image resizing
- Can specify up to 3 decimal places
- Can select rounding, floor, or ceiling methods
D2 Resize Calculator
- Calculated values are always multiples of 8
- Can select rounding, floor, or ceiling methods
D2 Size Selector
- A node that allows selecting image size from presets
Details
This is an example of obtaining the size from an image, enlarging it by 1.255 times, and then rounding the result.
Input
images- Used to obtain size from images
- Requires setting
presettocustom
preset- Size presets
- Must be set to
customwhen usingwidth,height, orimagessize - To change presets, edit
/custom_nodes/D2-nodes-ComfyUI/config/sizeselector_config.yaml
width/height- Vertical and horizontal dimensions
- Requires setting
presettocustom
swap_dimensions- Swaps width and height
upscale_factor- Value passed to other resize-related nodes
prescale_factor- Multiplier for resizing width / height
round_methodRound: Rounds to the nearest integerFloor: Rounds down
batch_size- Batch size to set for empty_latent
Output
width / height- Multiplies input
widthandheightbyprescale_factor
- Multiplies input
upscale_factor/prescale_factor- Passes through what was Input
empty_latent- Outputs latent created with specified size and batch size
batch_size- Passes through what was Input
D2 Refiner Steps
- A node that outputs steps for Refiner
Details
Input
steps- Total number of steps
start- Steps where the first KSampler starts
end- Steps where the first KSampler ends
Output
steps/start/end- Pass-through from Input
refiner_start- Steps where the second KSampler starts
D2 Refiner Steps A1111
- A node that can also specify denoise for Refiner in img2img
Details
Input
steps- Total number of steps
denoise- Specifies denoise for img2img
switch_at- At what percentage of total steps to switch to the next KSampler
Output
steps/- Pass-through from Input
start- Starting steps for the first KSampler
end- Ending steps for the first KSampler
refiner_start- Steps where the second KSampler starts
D2 Refiner Steps Tester
- A node for checking steps
Prompt convert dialog
- Dialog for converting weights between NovelAI and StableDiffusion formats
- Open from the
Prompt convertbutton - Hidden by default
- Enable
settings > D2 > Show prompt convert buttonto display
🗂️ Sample Workflow
You can recreate the workflow by dropping the image into ComfyUI.
Process all images in folder
Extracts prompts from images, replaces quality tags, applies ControlNet AnyTest, and upscales.

SDXL XY Plot
Switching quality tags based on Checkpoint's full path name

Switching Checkpoint midway with Refiner

💻 Installation Options
1. ComfyUI Manager Installation
ComfyUI Manager → Custom Node Manager → Search for D2 Nodes and install
2. Git Pull Method
In the custom_nodes folder, git clone
> git clone https://github.com/da2el-ai/D2-nodes-ComfyUI.git
🌼 Changelog
2024.11.02
- D2 Regex Switcher: Added toggle visibility for input text confirmation textarea
2024.10.28
- Prompt convert: Added a dialog for converting prompts between NovelAI and StableDiffusion formats
- D2 Folder Image Queue: Fixed a bug where the number of generated images was not consistent
2024.10.26
- Added new D2 EmptyImage Alpha
- Added new D2 Image Resize
- Added new D2 Resize Calculator
2024.10.24
- Added D2 Regex Replace
- Added D2 Folder Image Queue
- D2 Load Image: Added image path input
- D2 KSampler(Advanced): Added Positive / Negative Conditioning to Input
2024.10.19
- Added D2 Queue Button
2024.10.18
- D2 Size Selector: Added feature to obtain size from images
- D2 Size Selector: Made it possible to choose between "rounding" and "flooring" for resizing methods
2024.10.14
- D2 Load Image: Fixed an error that occurred when loading images without Exif data (such as those pasted from clipboard)
2024.10.11
- D2 Regex Switcher: Added the ability to specify the character to be inserted when concatenating strings
2024.10.10
- D2 Load Image: An "Open Mask Editor" button has been added.
2024.10.08
- D2 Load Image: Newly added
2024.10.03
- D2 Regex Switcher: Fixed a bug where matches were being overlooked during search
2024.10.02
- Created by integrating existing nodes

