CMK Image Metrics
The Node You Add When the Shape Is Wrong and Nothing Says Why
- image
- image
- width
- height
- batch_size
- channels
- diagnostic
Half of ComfyUI debugging is discovering that a tensor isn't the shape you assumed. Your detailer produced nothing because the mask was 512 wide and the image was 1024. Your batch of eight silently became a batch of one. Your node reports "image" and you have no idea whether it's a frame or a batch.
CMK Image Metrics is the five-second answer: wire it in, read the numbers.
What it does
It takes one image and returns six things: the image itself, unchanged, plus width, height, batch_size, channels as integers, plus a diagnostic payload.
The passthrough is the design choice that makes it usable. It's an inline probe - you drop it on a wire, it tells you the shape, and the signal keeps flowing to wherever it was going. No re-wiring, no second preview node, no changing the graph to inspect it.
The values come straight off the tensor: shape[0] is batch, shape[1] height, shape[2] width, shape[3] channels. If the input isn't a rank-3-or-better tensor, everything reports zero rather than raising - the node would rather give you a meaningless number and let you notice than fail the run.
That ordering trips people up the first time: ComfyUI image tensors are [batch, height, width, channels]. So a width of 1152 on a "832×1152" preset is correct, not a swap bug. Say it out loud once and you'll stop chasing it.
Numbers you can wire
Because width and height are real INT outputs - not just a text display - you can build on them. Feed widths into a math node, compare two stages of a pipeline, drive a conditional, or compute a scale factor from the actual pixels instead of a widget you typed last week.
That's the difference between this node and the pack's sibling inline diagnostic, which shows metrics in the node UI and exposes only the image. If you want to look, either does; if you want to compute, this one has the outputs.
diagnostic is the CMK diagnostic payload - a summary string, the metadata dictionary and the image as a preview. In a flow's visualizer, that's what makes the measurement part of the run record rather than something you scrolled past in the console.
Where this earns its keep
Debugging a mask/image mismatch. Print both. Nine times out of ten the failure is a shape disagreement, and the remaining one time you've saved yourself an hour of guessing.
Confirming a batch before a video run. Feeding a 300-frame sequence into something that wants one frame is much cheaper to catch here than three minutes into a swap.
Checking what a crop actually did. The pack's load-and-resize node crops to an aspect ratio by design. Measure before and after - that's the difference between trusting the crop and knowing it.
Catching a silent pass-through. Identical numbers on both sides of a module is how you discover the module didn't run, which is the failure mode CMK's whole enable/disable design is trying to make visible.
Install
Manager: search CMK Flow, install the CMKFlow entry, restart. Manually, from your ComfyUI root:
git clone https://github.com/CMKFlow/cmk_nodes.git custom_nodes/cmk_nodes
python3 custom_nodes/cmk_nodes/scripts/install_cmk_requirements.py
The helper is part of the install, not a nicety: a manual clone never runs pip, and the pack needs ultralytics, onnxruntime, insightface, segment-anything, imageio-ffmpeg, nudenet and opencv-python. Success looks like CMK dependency check: OK.
This node needs none of that - it's arithmetic on a tensor shape - which makes it a good first thing to add when you're not sure whether the pack installed properly. If metrics work and the swap nodes don't, the problem is a weight file:
python3 custom_nodes/cmk_nodes/scripts/check_cmk_resources.py --models-root "/path/to/ComfyUI-Shared"
And enable ComfyUI's Nodes 2.0 / Vue frontend setting; CMK warns at startup if it's off.
Gotcha
It reports what it's given, including an empty or malformed tensor - zeros across the board. That's a valid answer ("this isn't a normal image tensor") but it's easy to read as "everything is fine, size zero". If width and height are both 0, the input is the problem.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |
| batch_size | INT | — |
| channels | INT | — |
| diagnostic | CMK_DIAGNOSTIC | — |