Convert Tensor (NHWC) to (NCHW)
The Node That Does Nothing (and Why)
- image
- image
I'll get straight to it: this node does nothing. It claims to convert a tensor from NHWC layout (batch, height, width, channels - ComfyUI's native format) to NCHW (batch, channels, height, width - PyTorch/diffusers' format), and instead it just... prints. Here's the whole execute method:
def execute(self, image):
print(image.shape)
image.permute(0, 3, 1, 2)
print(image.shape)
return [image]
In torch, permute returns a new tensor - it is not in-place. The code calls it, discards the result, and returns the original unchanged. The two print statements will show you the exact same shape before and after, like a magic trick where the magician forgets the reveal. If you run this node, the only observable effect is two identical lines in your ComfyUI console.
What it was supposed to do
The intent is legible even through the bug. NCHW is what PyTorch models and diffusers pipelines expect internally, so the author wanted a helper that reorders a ComfyUI image tensor's dimensions before handing it to a diffusers-based InstantID pipeline. In that world, the conversion is meaningful. The problem is the implementation never got finished.
The second problem: it couldn't work even if it were fixed
Here's the subtle part. The output socket is typed IMAGE. ComfyUI's image tensors are NHWC by definition - that's the contract every image node agrees on, from LoadImage to VAEEncode to KSampler. If you "fixed" this node to actually return an NCHW tensor, you'd be returning something that violates the IMAGE contract, and every stock node downstream would either misinterpret it or crash. The only place an NCHW tensor is genuinely useful is inside a diffusers-style pipeline like the author's InstantID nodes - which is why this whole pack is best understood as scaffolding for that pipeline, not as general-purpose utilities for the normal graph.
What to use instead
- In a normal ComfyUI workflow: nothing. You don't need NCHW anywhere in stock ComfyUI. Delete the node.
- If you genuinely need NCHW (custom pipeline, debugging, feeding a diffusers model): do it in a
Pythonnode withtensor.permute(0, 3, 1, 2).contiguous(), or fix it upstream in the code - it's a one-line correction innodes.py.
Install
No README in the repo, so: ComfyUI Manager → search ComfyUI-InstantIDUtils, or
cd ComfyUI/custom_nodes
git clone https://github.com/BXYMartin/ComfyUI-InstantIDUtils
Restart after. No model downloads, no insightface. requirements.txt lists only diffusers, and this node doesn't even import it.
Troubleshooting
- "Nothing happens / identical shapes printed": not a bug in your setup - that's the node working as written. It's a no-op.
- You expected an NCHW tensor out: see above. It never happened, and even a fixed version wouldn't play nice with
IMAGEsockets. - The pack hasn't been touched since May 2024: this node was broken on arrival in March 2024 and nobody ever fixed it. That's the whole story.
It's tempting to call this the pack's worst node. It's also the most honest one, in a way: what you see is exactly what you get - nothing. At least the printed shapes are a convenient way to confirm your input was the shape you thought it was.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |