Nodes/ComfyUI-xiaozhuguang/小珠光反转遮罩极速版
ComfyUI Node

小珠光反转遮罩极速版

The fastest mask flip you'll find — and it's one line

By xiaozhuguang·Created 2 months ago·Updated a day ago· 56
小珠光反转遮罩极速版
  • mask
  • 遮罩

Mask inversion is the dullest operation in image editing: swap white for black, done. ComfyUI has a core InvertMask node that does it fine, so why does the Xiaozhuguang pack ship its own, and why does the display name brag about being "极速版" (speed edition)? Because the author wrote it the way you'd hope every trivial node was written - as a single tensor operation with no image round-trip, no channel juggling, no overhead worth naming.

The entire mechanism, from the pack's source: 1.0 - mask, straight on the tensor, with a one-line guard that adds a batch dimension if the mask arrived as a single 2D plane. That's it. Because it stays in tensor land and never converts to a PIL image, it runs on GPU, works on batched masks, and is effectively instant - you'll never notice it in a profile, which is the correct behavior for a node this small. The "speed edition" branding is fair: most invert implementations in other packs route through numpy or PIL conversions, and this one skips both.

Inputs and outputs are exactly what you'd expect for a utility this thin:

  • mask - the only input (MASK).
  • 遮罩 - the only output (MASK): the inverted mask.

If you're already running the Xiaozhuguang pack, reach for this instead of adding another pack just for an invert. If you're not running the pack, there's no strong reason to install a whole suite for this - ComfyUI's core node does the job, and honestly you won't feel a speed difference on a single mask. Where this earns its keep is inside a chained mask pipeline that runs per-frame on video: inverting a mask in the same tensor flow as the rest of your mask math, without ever bouncing through an image save, keeps the whole chain clean.

When would you actually use an inverted mask? Flip a subject mask and you've got a background mask - that's the classic compositing move for keep-background / remove-subject passes, and the masking KB's detection-and-detailing loop is full of places where you need "everything except the region." It's also handy right after a mask is generated white-on-black when your downstream node expects black-on-white.

Install is the pack standard: ComfyUI Manager → search ComfyUI-xiaozhuguang → install → restart, or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/xiaozhuguang/ComfyUI-xiaozhuguang

Restart, and it appears under the 小珠光 category (显示 "小珠光反转遮罩极速版" in Chinese until you switch UI language). It landed in v12.11.0 alongside the mask-preview node, so update the pack if you can't find it - and if your version is older than that, it simply doesn't exist yet. No models, no dependencies, nothing else to configure. Sometimes a node is just one line of math, and that's fine.

Categoryxiaozhuguang

Inputs (1)

NameTypeDefaultDescription
maskMASK

Outputs (1)

NameTypeDescription
遮罩MASK