Nodes/ComfyUI-QING/遮罩分析丨数据
ComfyUI Node

遮罩分析丨数据

Know exactly what your mask covers — before you burn a sampler pass

By sheengoa·Created about a year ago·Updated 20 days ago· 16
遮罩分析丨数据
  • mask
  • 批次
  • 宽度
  • 高度
  • 覆盖率
  • 信息

An inpaint or detail pass is only as good as the mask it runs on - and a mask that looks fine in a preview can be covering 0.5% of the frame when you actually need 15%, or vice versa. MaskDataAnalyzer is the node that tells you the truth in numbers: batch size, width, height, coverage ratio, and a full text report with a quality judgment. It's the "check before you spend" node for the masking-detection-detailing workflow.

It's from ComfyUI-QING (display name "遮罩分析丨数据"), the mask-flavored sibling of the pack's ImageDataAnalyzer - same design, one extra, very useful output.

How it works

One optional mask input, no required inputs. Wire a MASK in and it inspects the tensor:

  • batch, width, height as clean INTs
  • 覆盖率 (coverage ratio) - a FLOAT 0–1: the fraction of pixels where the mask is above 0.5. This is the number that matters.
  • 信息 (info) - a STRING with the full report: shape, device, dtype, total pixels, estimated memory, value range, mean, covered pixel count, and a quality label - 几乎空白 (nearly blank, <1%), 稀疏覆盖 (sparse, <10%), 部分覆盖 (partial, <50%), 大面积覆盖 (large, <90%), or 几乎全覆盖 (nearly full).

The quality tiers aren't decoration - they're a cheap sanity check that a segmentation actually found what it was supposed to. A subject mask at 2% coverage when you expected 40% means the detector failed, and you'll know before the sampler runs.

The output that changes your workflow

The coverage ratio as a FLOAT is the reason to add this node to a real pipeline, not just a debugging session. Because it's a real number, you can gate logic on it: feed 覆盖率 into a comparison node and branch - "if coverage < 1%, skip the detail pass entirely; if it's between 1% and 40%, run it; if it's > 90%, the mask is probably garbage, log a warning." That turns the node from a readout into a quality gate, which is exactly the automation the masking playbook says to build ("a program finds the region for you"). The whole "when it helps and when it hurts" judgment from that doc becomes a comparison node instead of a human eyeballing a preview.

Same trick works with the 宽度/高度 INTs - verify a mask is at the resolution you expect before it feeds a blend or an inpaint, so a mis-sized mask never silently corrupts a pass.

Installing

Part of ComfyUI-QING. ComfyUI Manager: search "ComfyUI-QING". Or:

cd ComfyUI/custom_nodes
git clone https://github.com/GAO-SHIQING/ComfyUI-QING
cd ComfyUI-QING
python install_dependencies.py   # or: pip install -r requirements.txt

Restart ComfyUI. Pure pip deps, no models. China mirror: --mirror --auto. Python ≥ 3.9.

Gotchas

The coverage math uses a hardcoded 0.5 threshold for "selected" - a soft mask where most pixels sit at 0.4 will read as near-blank even though it visually covers things. If you're analyzing feathered or gradient masks, the number is directional, not gospel; binarize first (e.g. with MaskBlend's threshold) if you need an exact count. And no input wired → all zeros + "无遮罩输入", which is the pack's friendly way of saying "you forgot to connect it." Also note the memory figure assumes float32 regardless of actual dtype - treat it as an estimate.

CategoryQING/数据工具

Inputs (1)

NameTypeDefaultDescription
maskoptMASK

Outputs (5)

NameTypeDescription
批次INT
宽度INT
高度INT
覆盖率FLOAT
信息STRING