Extensions/comfyui_bmad_nodes
ComfyUI Extension Runs on cloud

comfyui_bmad_nodes

Utility nodes for ComfyUI

By bmad4ever·Created 3 years ago·Updated about a year ago· 64
bmad4ever/comfyui_bmad_nodes
Nodes123
On cloudRunnable
CategoryBmad/CV/Thresholding, Bmad/image
Stars64
Updatedabout a year ago

Nodes (123)

AdaptiveThresholding

The threshold that survives shadows and uneven light

Bmad/CV/Thresholding
AddAlpha

Give a flat RGB image a real alpha channel

Bmad/image
Add String To Many

Append one string to a dozen prompts without a dozen extra nodes

Bmad/conditioning
AdjustRect

Snap a crop rectangle to latent-friendly multiples without moving its center

Bmad
AnyToAny

A Python eval in your graph — powerful, and the pack will warn you about it

Bmad/⚠️⚠️⚠️
BoundingRect (contours)

From 'there's a shape here' to four crop coordinates

Bmad/CV/Contour
BuildColorRangeAdvanced (hsv)

For when a percentage knob isn't enough to mask your color

Bmad/CV/Color A.
BuildColorRangeHSV (hsv)

Point at a color, get the mask range for it — statistically

Bmad/CV/Color A.
ChameleonMask

Give it a clean reference and it finds what changed — a mask of the difference

Bmad/CV/C.Photography
CheckpointLoader (dirty)

The checkpoint loader whose filename is a text box, built for API automation

Bmad/api/dirty loaders
CheckpointLoaderSimple (dirty)

The simple loader, minus the dropdown, for scripts that know the filename

Bmad/api/dirty loaders
CLAHE

The fix for uneven lighting before you even think about thresholding

Bmad/CV/Thresholding
CLIPEncodeMultiple

A whole prompt queue through one CLIP node

Bmad/conditioning
Color Clip

Chromakey for flat-color images

Bmad/image
Color Clip ADE20k

Clip ADE20k segmentations by label

Bmad/image
Color Clip (advanced)

Color Clip, but you pick the replacement colors too

Bmad/image
ColorDictionary

A ready-made palette of named colors for the CV nodes

Bmad/CV/Color A.
ColorDictionary (custom)

Build your own named color dictionary

Bmad/CV/Color A.
Color (hexadecimal)

Feed hex codes into ComfyUI's color-masking machinery

Bmad/image
Color (RGB)

The color picker this pack expects

Bmad/image
Conditioning Grid (cond)

Regional prompting as a grid, without the spaghetti

Bmad/conditioning
Conditioning Grid (string)

Type prompts straight into the grid, skip the encoders

Bmad/conditioning
Contours

Find the shapes in your mask, the OpenCV way

Bmad/CV/Contour
Contour To Mask

Turn one contour back into a filled mask

Bmad/CV/Contour
ControlNetHadamard

ControlNet per-pair, not per-everything

Bmad/conditioning
ControlNetHadamard (manual)

ControlNetHadamard, when your images come one at a time

Bmad/conditioning
ConvertImg

Make a node see the channel count it expects

Bmad/CV
CopyMakeBorder

Pad an image with a border, five ways

Bmad/CV/Misc
CreateRequestMetadata

A JSON breadcrumb so scripts know what your render did

Bmad/api
DistanceTransform

How far is every pixel from the edge? This node answers that

Bmad/CV/Thresholding
Draw Contour(s)

See the contours you found, on top of the image

Bmad/CV/Contour
EqualizeHistogram

Stretch a washed-out image before you threshold it

Bmad/CV/Thresholding
ExtendColorList

Concatenate color lists, the boring node that earns its place

Bmad/Lists/Extend
ExtendCondList

Merge conditioning lists before they hit the sampler

Bmad/Lists/Extend
ExtendFloatList

The Boring Node That Glues Your Float Lists Together

Bmad/Lists/Extend
ExtendImageList

Stacking Image Lists for Grids, Batches and Video

Bmad/Lists/Extend
ExtendIntList

Concatenate Int Lists When You Refuse to Count Manually

Bmad/Lists/Extend
ExtendLatentList

Merging Latent Batches Without Re-Encoding a Thing

Bmad/Lists/Extend
ExtendMaskList

Joining Mask Lists When You're Compositing a Whole Scene

Bmad/Lists/Extend
ExtendModelList

One List of Models Instead of Ten Loaders

Bmad/Lists/Extend
ExtendStringList

Merging Prompt Lists Without Merging Your Brains

Bmad/Lists/Extend
FadeMaskEdges

Stop the Ugly White Halo When You Composite a Cutout

Bmad/CV/Misc
Filter Contour

Rank Shapes With a One-Line Fitness Function

Bmad/CV/Contour
FindComplementaryColor

Ask the Image What Color It's Missing

Bmad/CV/Color A.
FindThreshold

Auto-Tune the Threshold That Gets You the Mask You Want

Bmad/CV/Thresholding
FlatLatentsIntoSingleGrid

Turn a Latent Batch Into One Big Grid Latent

Bmad/latent
Framed Mask Grab Cut

OpenCV's GrabCut With the Background Pointed Out For You

Bmad/CV/GrabCut
Framed Mask Grab Cut 2

GrabCut With Separate 'Maybe' and 'Sure' Foregrounds

Bmad/CV/GrabCut
FromListGet1Color

Index Into a Palette List

Bmad/Lists/Get1
FromListGet1Cond

Pull One Conditioning Out of a Stack

Bmad/Lists/Get1
FromListGet1Float

Pull One Float Out of a List Without a Whole New Node

Bmad/Lists/Get1
FromListGet1Image

Pick One Frame From an Image List

Bmad/Lists/Get1
FromListGet1Int

Grab One Integer From a List, Negative Indexes Welcome

Bmad/Lists/Get1
FromListGet1Latent

Extract One Latent From a Batch Without Re-Encoding

Bmad/Lists/Get1
FromListGet1Mask

Grab one mask out of a mask list by number — FromListGet1Mask

Bmad/Lists/Get1
FromListGet1Model

Index into a model list without rebuilding the graph — FromListGet1Model

Bmad/Lists/Get1
FromListGet1String

Pick one string out of a list for prompt roulette — FromListGet1String

Bmad/Lists/Get1
FromListGetColors

Fan a color palette out into per-color sockets — FromListGetColors

Bmad/Lists/GetAll
FromListGetConds

Unpack a conditioning list into per-region sockets — FromListGetConds

Bmad/Lists/GetAll
FromListGetFloats

Fan an float list out into parameter sockets — FromListGetFloats

Bmad/Lists/GetAll
FromListGetImages

Fan an image batch out into individual sockets — FromListGetImages

Bmad/Lists/GetAll
FromListGetInts

Unpack an int list for per-branch settings — FromListGetInts

Bmad/Lists/GetAll
FromListGetLatents

Split a latent batch into single latents — FromListGetLatents

Bmad/Lists/GetAll
FromListGetMasks

Split a mask list back into individual sockets — FromListGetMasks

Bmad/Lists/GetAll
FromListGetModels

Unpack a model list into sampler branches — FromListGetModels

Bmad/Lists/GetAll
FromListGetStrings

Split a string list into individual sockets — FromListGetStrings

Bmad/Lists/GetAll
Get Contour from list

Pick one OpenCV contour out of the pile — Get Contour from list

Bmad/CV/Contour
Get Models

Your API script's way to know what models actually exist

Bmad/dump
Get Prompt

Dump your workflow as API JSON from inside ComfyUI — Get Prompt

Bmad/dump
Hue Mode (InRange hsv)

Set how hue wraps in color thresholding — Hue Mode (InRange hsv)

Bmad/CV/Thresholding
HypernetworkLoader (dirty)

Load a hypernetwork by typed name, not dropdown — HypernetworkLoader (dirty)

Bmad/api/dirty loaders
ImageBatchToList

Split a batch into a list so nodes process one at a time

Bmad/image
Inpaint

OpenCV inpainting — not diffusion, and that's the point — Inpaint

Bmad/CV/C.Photography
Input/String to Int Array

Turn '1,2,3' into an INT_ARRAY — and survive API JSON while you're at it

Bmad/api/parseInput
InRange (hsv)

Chroma-key a color range out of an image — InRange (hsv)

Bmad/CV/Thresholding
KMeansColor

Posterize an image down to N dominant colors — KMeansColor

Bmad/CV/Color A.
Load 64 Encoded Image

Turn a base64 blob into an image — no API key required — Load 64 Encoded Image

Bmad/api
LoraLoader (dirty)

Type your LoRA name instead of picking it — when your workflow runs itself

Bmad/api/dirty loaders
MaskGrid N KSamplers Advanced

One sampler, many grid cells — DIY regional control without the regional packs

Bmad/experimental
MaskOuterBlur

Blur the outside of a mask, not the inside — the collage secret nobody ships

Bmad/CV/Misc
Merge Latent Batch Gridwise

Stitch a batch of latents back into one image — the other half of the grid trick

Bmad/latent
MonoMerge

Merge two masks by max or min — the two-line idea that saves you a node pack

Bmad/image
MorphologicOperation

Erode, dilate, open, close — the mask-cleaning kit you keep reaching for

Bmad/CV/Morphology
MorphologicSkeletoning

Reduce a fat mask to a one-pixel line — for measuring, tracing, and contour work

Bmad/CV/Morphology
NaiveAutoKMeansColor

Posterize automatically — let the elbow decide how many colors the image actually has

Bmad/CV/Color A.
OtsuThreshold

Stop hand-tuning thresholds — Otsu finds the line between black and white for you

Bmad/CV/Thresholding
Rect Grab Cut

Cut a subject out of a photo with one rectangle — no model, no prompt, just OpenCV

Bmad/CV/GrabCut
Remap

The sink node every Remap distorts into — without it, the family is just math

Bmad/CV/Transform
RemapBarrelDistortion

Add or remove real lens distortion — the a/b/c/d of barrel and pincushion

Bmad/CV/Transform
RemapFromInsideParabolas

Unwrap a curved band back into a flat strip — the reverse of the parabola bend

Bmad/CV/Transform
RemapFromQuadrilateral (homography)

Straighten the tilted document, screen, or sign

Bmad/CV/Transform
RemapInsideParabolas

Bend a straight strip along two curves — the 'wrap text around a shape' trick

Bmad/CV/Transform
RemapInsideParabolasAdvanced

Curve-fit fixes for when the simple parabola warp comes out twisted

Bmad/CV/Transform
RemapPinch

Squeeze a photo toward its center — the lens effect with three knobs

Bmad/CV/Transform
RemapReverseBarrelDistortion

The proper way to undo a lens bend — root-finding instead of a shortcut formula

Bmad/CV/Transform
RemapStretch

Push a photo outward from its center — the bulge that pinch's inverse gives you

Bmad/CV/Transform
RemapToInnerCylinder

Wrap a flat image around the inside of a cylinder — your wide-lens room view

Bmad/CV/Transform
RemapToOuterCylinder

Wrap an image around the outside of a cylinder — label-on-a-bottle, done in two knobs

Bmad/CV/Transform
RemapToQuadrilateral

Perspective-paste one image onto any tilted surface

Bmad/CV/Transform
RemapWarpPolar

RemapWarpPolar for watch faces, dials and iris shots

Bmad/CV/Transform
Repeat Into Grid (image)

Repeat Into Grid (image) makes contact sheets without touching a pixel

Bmad/image
Repeat Into Grid (latent)

Repeat Into Grid (latent) tiles before the VAE decode

Bmad/latent
RequestInputs

Unpack a JSON request straight into your ComfyUI graph

Bmad/api
RGB to HSV

Get a color into the scale OpenCV's masking actually wants

Bmad/CV/Color A.
SampleColorHSV

Stop guessing HSV bounds, steal them from a reference image

Bmad/CV/Color A.
Save Image (api)

The request-driven saver that skips the workflow metadata

Bmad/api
SeamlessClone

Paste anything into a photo and watch the seams vanish

Bmad/CV/C.Photography
SeamlessClone (simple)

The same magic, minus the placement math

Bmad/CV/C.Photography
SetRequestStateToComplete

SetRequestStateToComplete closes out an API request

Bmad/api
String

The text node at the root of every prompt branch

Bmad
String to Float

The float twin of String to Integer, for when your API sends decimals as text

Bmad/api/parseInput
String to Integer

The boring node that keeps your API workflow alive

Bmad/api/parseInput
ToColorList

Bundle your palette colors into a list

Bmad/Lists/Make or Intercalate
ToCondList

Bundle your conditionings into one list wire

Bmad/Lists/Make or Intercalate
ToFloatList

Gather your weights, CFG values and denoise levels into a list

Bmad/Lists/Make or Intercalate
ToImageList

Gather separate images into a single list

Bmad/Lists/Make or Intercalate
ToIntList

Collect your seeds, steps and counts into a list

Bmad/Lists/Make or Intercalate
ToLatentList

Collect loose latents into one list

Bmad/Lists/Make or Intercalate
ToMaskList

Bundle your masks into one list

Bmad/Lists/Make or Intercalate
ToModelList

Line up several models into one list

Bmad/Lists/Make or Intercalate
ToStringList

Gather your prompts and text into a list

Bmad/Lists/Make or Intercalate
UnGridify (image)

UnGridify (image)

Bmad/image
VAEEncodeBatch

One latent batch from many images (no wiring gymnastics)

Bmad
Readme

ComfyUI Bmad Nodes

Miscellaneous assortment of custom nodes for ComfyUI.

The nature of the nodes is varied, and they do not provide a comprehensive solution for any particular kind of application. The nodes can be roughly categorized in the following way:

  • api: to help setup api requests (barebones).
  • computer vision: mainly for masking and collage purposes.
  • general utility: simplify the workflow setup or implement some missing basic functionality.

<details><summary> Documentation </summary>

In order to keep the documentation brief and to the point, I will use the following icons for special nodes.

  • ❔ the node has additional options when right-clicking, some of these options need to be used for the node to work.
  • 📓 the node depends on an external library, and the requirements must be installed for it to work.
  • 📄 the node relies on custom nodes external to this collection, they will only work if the needed nodes are installed.
  • ❌the node won't work on vanilla comfyUI at the time of writing.
  • ⚠️the node is potentially dangerous. Although they should be fairly safe in most cases, it is NOT advised to run them from unknown sources unless you know what they are doing. For better visibility these nodes are forcefully painted white.

Furthermore, I won't provide any documentation for api nodes, as I think there are better, more comprehensive and already documented, solutions available.

General Purpose

| Node | Description | |------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | String | Just a string (text). In case you want it written before connecting to a node or if some custom node does not work properly with the PrimitiveNode. | | Add String to Many ❔ | Will append/prepend the string to_add to all the other strings. | | Color Clip | Clips the color (or all the other colors) from an image. Both the target color or the complement can be set to white, black or remain untouched. | | Color Clip ADE20k 📓️ | Similar to Color Clip, but you pick the color from the ADE20k class list. Only useful for ADE20k semantic segmented images. | | MonoMerge | Selects the maximum (or minimum) value between two images. Mainly used for mask composition. | | AdjustRect | Receives a rectangle and returns a new rectangle that shares the same center but with width adjusted to a multiple of xm and height to a multiple of ym. Setting round_mode to exact will return a rectangle with the exact defined dimensions. | | Repeat Into Grid | Tiles the provided image/latent into a grid of columnsxrows tiles. | | Conditioning Grid (cond) ❔ | Creates conditioning areas of size widthxheight, forming a grid of columnsxrows conditioning areas. The inputs notation can be read as: r{row}_c{column}. strength is the strength to by applied in all the areas, and base is the base conditioning prior to setting the tiles conditioning. | | Conditioning Grid (string) ❔ | Similar to Conditioning Grid (cond), but generates the conditioning from the given strings (only). | | Conditioning Grid (string) Advanced 📄 ❔ | Similar to Conditioning Grid (string), but requires BlenderNeko's Advanced CLIP Text Encode. | | VAEEncodeBatch ❔ | Receives multiples images and encodes them into a latent batch. | | AnyToAny ❌ ⚠️ | Can be used to convert data between different formats or compute stuff. The input data can be used in the expression using the letter v. | | CLIPEncodeMultiple ❔ | Receives individual strings → CLIPEncodes each → returns conditioning list. | | CLIPEncodeMultipleAdvanced 📄 ❔ | Same as CLIPEncodeMultiple, but using BlenderNeko's Advanced CLIP Text Encode. | | ControlNetHadamard | Receives a list of conditionings and a list of images → Applies contronet only once per conditioning/image pair (does not apply every image to every conditioning). | | ControlNetHadamard (manual) ❔ | Similar to ControlNetHadamard but images are set via individual inputs. | | ToCondList ❔ | Receives individual conditionings → returns a list with all the input conditionings. | | ToLatentList ❔ | Receives individual latents → returns a list with all the input latents. | | ToImageList ❔ | Receives individual images → returns a list with all the input images. | | FromListGetConds ❔ | Receives a list of conditionings → returns the conditionings via individual slots. | | FromListGetLatents ❔ | Receives a list of latents → returns the latents via individual slots. | | FromListGetImages ❔ | Receives a list of images → returns the images via individual slots. |

CV (Computer Vision) nodes

Nodes under the CV separator use or expose openCV functionalities.

I will only provide partial documentation here, to clarify how to use the more complex nodes. The remaining nodes usage should be clear given the nodes' names.

Framed Mask Grab Cut

Returns a mask, in image format, with the result of the grabcut.

<details> <summary> usage </summary>

The tresh input should be a gray image, possibly a mask in black and white but not necessarily (read thresholds). It is used to set most of the grabcut input mask's flags, excluding GC_BGD (sure background) which are set by the "frame".

The "frame" - border margins of the image - has its size defined via the pixels input, and won't affect sides set to be ignored by the frame_option input (the corners common to neighbor sides will still be painted on the ignored sides).

The threshold inputs indicate the intensity threshold's used to set GC_PR_FGD (probable foreground) or GC_FGD (foreground). The values equal or above the thresholds are set with the indicated flag. They can be setup in the following manners:

  • To only use probable foreground, set threshold_FGD to exactly 0, and it will be ignored.
  • To only use foreground, set threshold_FGD to a lower value than threshold_PR_FGD.
  • To have both, keep threshold_FGD higher than threshold_PR_FGD (make sure your thresh input image contains values in the intended range).

The thresholds also work as safeguards against potential misleading or inconsistent input images, where the image may appear to be only black and white, but actually contains values besides 0s and 255s.

Framed Mask Grab Cut 2

Similar to Framed Mask Grab Cut, but uses thresh_maybe to set the probable foreground, and thresh_sure to set the foreground. The threshold value is the same for both thresh image inputs; the GC_FGD flags are set by the thresh_sure on top of the GC_PR_FGD flags set by thresh_maybe.

</details>

Filter Contour ⚠️

Will output contours depending on their fitness, where the fitness function must be provided within the node's text box.

The expression may be long but can't have multiple instructions, only a single line that returns the fitness when evaluated.

<details> <summary> usage </summary>

Select argument options:

  • MAX, MIN: select the contour (singular) with higher and lower fitness respectively, the evaluated expression should result in a number.
  • FILTER: filters the contours (plural) that satisfy the fitness condition, the evaluated expression should result in a boolean.
  • MODE: selects the contour (singular) whose fitness score is the mode of all the contours fitness scores.

To compute the fitness, the input parameters can be used with the following names:

  • c: the contour being evaluated, from input contours
  • i: input image (optional)
  • a: input auxiliary contour (optional)

Functions from the math, opencv and numpy modules can be used with the prefixes: m; cv; and np, respectively. Additionally, functions listed below can also be used without a prefix.

The following is an example fitness function to get the contour that best matches the auxiliary contour (the lower the value, the better the match):

cv.matchShapes(c,a,1,0.0)

List of available functions:

  • aspect_ratio(contour): bounding rectangle's width divided by height
  • extent(contour): contour area divided by bounding rect area
  • solidity(contour): contour area divided by hull area
  • equi_diameter(contour): how round is the shape math.sqrt(4 * area / math.pi)
  • center(contour)
  • contour_mask(contour, image)
  • mean_color(contour, image)
  • mean_intensity(contour, image)
  • extreme_points(contour)
  • intercepts_mask(contour, image) does not cache result

All the listed functions cache the results at least once (details vary); they don't create computational overhead for being called more than once. This behavior was also added to the following list of opencv functions, which must be called without the cv prefix:

  • boundingRect
  • contourArea
  • arcLength (called without the boolean arg; is always sent with true)
  • minEnclosingRect
  • minEnclosingCircle
  • fitEllipse
  • convexHull
</details> </details>