KJNodes/maskinggenerated

Batch CLIPSeg(BatchCLIPSeg)

This node technically utilizes a pre-trained CLIPSeg model to align the input text prompt with image features and calculates the relevance score of each pixel to the text.

Batch CLIP Seg

images
opt_model
prev_mask
Mask
Image
text
STRING
threshold
0.500
binary_mask
combine_mask
use_cuda
blur_sigma
0.0
image_bg_level
0.50
invert
KJNodes

The Batch CLIPSeg node technically utilizes a pre-trained CLIPSeg model to align input text prompts with image features and calculates the relevance score between each pixel and the text.

The Batch CLIPSeg node is an image segmentation tool based on the CLIP model, capable of automatically generating corresponding masks for an image or a batch of images based on text descriptions. Its core function is to transform natural language instructions into precise selections of visual regions, enabling semantically-driven mask creation.

Node Function

This node technically utilizes a pre-trained CLIPSeg model to align input text prompts with image features and calculates the relevance score between each pixel and the text. It supports processing batch inputs of the IMAGE type, consisting of single or multiple images. It converts the relevance score map into binary or continuous masks through thresholding and optionally applies post-processing such as Gaussian blur to the masks.

Node Parameter Description - Batch CLIPSeg

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
imagesIMAGEYes--images (Input Parameter): Input image(s) or image batch to be segmented. Supports single or multiple images.
opt_modelCLIPSEGMODELNo--opt_model (Input Parameter): Optional external CLIPSeg model input, used to replace the default model loaded internally by the node.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
textSTRINGYes--"sky".
thresholdFLOATYes0.50.0 - 10.0 (Step: 0.001)threshold (Input Parameter): Sets the confidence threshold for segmentation; regions above this value are retained. Range 0.0 - 10.0, step 0.001.
binary_maskBOOLEANYesTrue-binary_mask (Input Parameter): Controls whether to binarize the mask (black and white). If false, outputs a continuous grayscale mask.
combine_maskBOOLEANYesFalse-combine_mask (Input Parameter): Controls whether to combine all currently generated masks into a single mask.
use_cudaBOOLEANYesTrue-use_cuda (Input Parameter): Controls whether to use CUDA (GPU) for accelerated computation to improve processing speed.
blur_sigmaFLOATNo0.00.0 - 100.0 (Step: 0.1)-
prev_maskMASKNoNone--
image_bg_levelFLOATNo0.50.0 - 1.0 (Step: 0.01)-
invertBOOLEANNoFalse--

Output

Parameter NameData TypeDescription
MaskMASKMask (Output Parameter): The output mask, which can be used by subsequent image processing nodes.
ImageIMAGEImage (Output Parameter): The output image, typically the same as the input image, used for workflow continuity.

Usage Scenarios

In practical applications, this node is commonly used in workflows requiring automated matting based on object or scene descriptions. For example, when batch processing product images, you can input the text "a shoe" to quickly generate precise masks of the shoes for all images containing shoes, facilitating subsequent background replacement or local adjustments.

Notes

The node's processing speed is affected by the model size and whether GPU acceleration is used. For high-resolution images or large batches, processing time may be longer. Furthermore, segmentation accuracy largely depends on the accuracy of the text description and the coverage of the model's training data.

The Batch CLIPSeg node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…