Nodes/Image Misc/Normalize Image to ImageNet
ComfyUI Node

Normalize Image to ImageNet

The preprocessing every ImageNet-trained model expects

By set-soft·Created about a year ago·Updated 8 months ago· 2
Normalize Image to ImageNet
  • image
  • image

If you've ever loaded a vision model - a ResNet, a VGG, a face encoder, pretty much anything pre-trained on ImageNet - you've seen its docs demand that images be "normalized with mean [0.485, 0.456, 0.406] and std [0.229, 0.224, 0.225]" before feeding them in. That specific incantation is the dataset's per-channel statistics, and models trained on ImageNet have these baked into how they expect their input. This node is that incantation as a one-click ComfyUI node.

The operation per channel is the standard (input - mean) / std. The constants are hardcoded from the ImageNet training set - the classic torchvision values that appear in countless model cards and tutorials. Feed it any ComfyUI image tensor in [0, 1] range and it returns the normalized result, ready to hand to whatever model needs it.

Why you'd bother

ComfyUI's image tensors live in [0, 1] by default, and ComfyUI's own generation models are fine with that. But the moment you step outside generation into the classification/vision side of the ecosystem - an image encoder for a pipeline, a similarity model, a quality scorer, anything that wraps an ImageNet-pretrained backbone - the model was trained on normalized inputs, and skipping this step quietly degrades results. It's not that the model errors; it's that features get computed on inputs shifted by a constant, and embeddings drift subtly. This node exists so that step is impossible to get wrong.

Inputs and outputs

  • image - the input tensor, [0, 1] range.
  • image (output) - the normalized tensor. The value range changes significantly; values will fall roughly in [-2.5, 2.5], and that's expected and correct for what it's feeding.

Installing it

Part of Image Misc:

cd ComfyUI/custom_nodes
git clone https://github.com/set-soft/ComfyUI-ImageMisc
cd ComfyUI-ImageMisc && pip install -r requirements.txt

or ComfyUI Manager → "Image Misc", then restart. Under image/normalization.

Notes

One thing to keep straight: normalization is not a display operation. If you put a preview after this node, it'll look wrong - dark, weird colors, clipped - because preview nodes assume [0, 1]. Wire this node directly into the model input and keep any previews upstream. Also, if the model you're feeding expects a different range (like [-1, 1]), don't reach for this one - the same pack has Normalize Image to [-1, 1] and [-0.5, 0.5] for those, plus an Arbitrary Normalize pair for anything custom. Use the recipe the model's documentation actually specifies.

Categoryimage/normalization

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
imageIMAGE