BadCafeCode / masquerade-nodes-comfyui

A powerful set of mask-related nodes for ComfyUI
MIT License
364 stars 36 forks source link

Recommended Alternatives

This node pack was created as a dependency-free library before the ComfyUI Manager made installing dependencies easy for end-users.

Unless you specifically need a library without dependencies, I recommend using Impact Pack instead. It's a more feature-rich and well-maintained alternative for dealing with masks and segmentation.

Masquerade Nodes

This is a node pack for ComfyUI, primarily dealing with masks. Some example workflows this pack enables are:

(Note that all examples use the default 1.5 and 1.5-inpainting models. Results are generally better with fine-tuned models.)

  1. Fine control over composition via automatic photobashing (see examples/composition-by-photobashing.json) CompositionExample
  2. Inpaint all faces at a higher resolution (see examples/inpaint-faces.json) FaceInpaintingExample
  3. Inpaint all buildings with a particular LORA (see examples/inpaint-with-lora.json) LoRAInpaintingExample
  4. Filtering out images/change save location of images that contain certain objects/concepts without the side-effects caused by placing those concepts in a negative prompt (see examples/filter-by-season.json) FilterImagesExample

The lynchpin of these workflows is the Mask by Text node. This node makes use of ClipSeg to dynamically create masks from images via text prompts.

Node Descriptions

Mask By Text

Inputs

Tips

Mask Morphology

Inputs

Outputs

  1. The resultant mask.

Tips

Combine Masks

Inputs

Outputs

  1. The resultant mask or image.

Tips

Unary Mask Op

Inputs

Outputs

  1. The resultant mask.

Tips

Unary Image Op

This node is the same as Unary Mask Op, but will operate across all channels of an image individually. This can be particularly useful after converting to HSV colorspace.

Inputs

Outputs

  1. The resultant image.

Blur

Inputs

Outputs

  1. The resultant mask or image.

Tips

Image To Mask

Inputs

Outputs

  1. The resultant mask in a form usable by inpainting.

Mix Images By Mask

Inputs

Outputs

  1. The resultant image.

Mix Color By Mask

Inputs

Outputs

  1. The resultant image.

Mask To Region

Inputs

Outputs

  1. A mask of the resultant region.

Tips

Cut By Mask

Inputs

Outputs

  1. The resultant image or mask.

Notes

Tips

Paste By Mask

Inputs

Tips

Get Image Size

Inputs

Outputs

  1. The width of the image.
  2. The height of the image.

Notes

Change Channel Count

Inputs

Outputs

  1. The resultant image.

Notes

Constant Mask

Inputs

Outputs

  1. The resultant mask.

Tips

Prune By Mask

Inputs

Outputs

  1. The pruned batch of images. Only images with an associated mask with an average value greater than 0.5 will be included.

Tips

Separate Mask Components

Inputs

Outputs

  1. A batch of masks. Each contiguous area of the mask will be separated into its own mask. Any values greater than 0 are considered part of a contiguous area.
  2. A mapping from the original mask to the new masks. This is useful when using Cut By Mask and Paste By Mask when a batch size larger than one was fed into this node.

Create Rect Mask

Inputs

Create QR Code

Inputs

Convert Color Space

Inputs

Incrementer

Inputs