ComfyUIImageToPytorchTENSOR
The adapter that hands ComfyUI images to your PyTorch nodes
- image
- b,h,w,c
- b,h,w,mean(c)
Everything in ComfyUI that renders an image hands you an IMAGE tensor. Everything in this pack's ML world eats a TORCH_TENSOR. ComfyUIImageToPytorchTENSOR is the bridge: feed it any IMAGE and it comes out the other side as a proper PyTorch tensor the rest of the EternalKernel nodes understand. The name is long, the job is short, and it's the first node you'll grab in any workflow that wants to feed real images into a TrainModel or PyTorchInferenceNode.
The README is honest about this one: it "just renames the object for compatibility with comfyui→pytorch." Under the hood it's two lines - it converts the image to a tensor and passes it through. If you expected deep conversion magic, you'll be slightly let down; the real work is that ComfyUI's IMAGE is already a float tensor in (batch, height, width, channels) with values 0–1, so "conversion" mostly means typing.
What you get out
Two outputs, and the second one is the sleeper:
- b,h,w,c (
TORCH_TENSOR) - the image itself, as a tensor in(batch, height, width, channels)layout. Wire this into the pack's tensor utilities or training nodes. - b,h,w,mean(c) (
TORCH_TENSOR) - the image with the channel dimension collapsed by averaging, giving(batch, height, width)grayscale-ish values. Handy if you're building a network that takes luminance or a single-channel input.
Input
- image (
IMAGE) - any ComfyUI image:LoadImage,VAEDecode, a preview, whatever.
Install
ComfyUI Manager, search "EternalKernel PyTorch Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/TashaSkyUp/EternalKernelPytorchNodes
cd EternalKernelPytorchNodes
pip install -r requirements.txt
Restart ComfyUI; node under ETK/pytorch. No model files. Requirements are the standard ComfyUI stack plus scipy, scikit-learn, transformers, einops.
Common issues
- Channel-last layout travels with you. This node does not permute anything. Your
b,h,w,ctensor is channel-last, andnn.Conv2dwantsb,c,h,w. If you feed this straight into a conv model, the "channels" it sees are actually spatial positions. You'll need a permute step (outside this pack) before a conv layer. - It's a copy, not a view. The output is
torch.tensor(image), a fresh tensor. Modifying it won't corrupt the original image node - usually what you want. mean(c)output shape. It's(batch, height, width)- three dims, not four. If a downstream node expects a channel axis, this one will surprise you.
Real talk: for loading an image as a tensor you could just as easily use any "IMAGE to tensor" node from a more popular pack. This one exists so the EternalKernel family stays self-contained. It's the pack's own interface convention - and since the whole pack speaks TORCH_TENSOR, it's the natural front door. Small, quiet pack, no tutorials; the fix to anything weird is usually a wire-type check, especially since the pack patches ComfyUI's validator to ignore return_type_mismatch errors.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| b,h,w,c | TORCH_TENSOR | — |
| b,h,w,mean(c) | TORCH_TENSOR | — |