Nodes/Image Misc/Normalize Image to [-1, 1] (i.e. GAN)
ComfyUI Node

Normalize Image to [-1, 1] (i.e. GAN)

The [-1, 1] input range your GAN-style model actually wants

By set-soft·Created about a year ago·Updated 8 months ago· 2
Normalize Image to [-1, 1] (i.e. GAN)
  • image
  • image

This is the normalization recipe that practically defines GANs. The display name spells it out: i.e. GAN. The classic image-to-image GAN lineage - Pix2Pix, CycleGAN, and most of the models that followed them - scales inputs into [-1, 1], because their generators end in a tanh activation, which outputs in that range. Feed such a model [0, 1] images and you're giving it half of what it expects. This node fixes that with two steps per channel: subtract 0.5, then divide by 0.5, i.e. output = (input - 0.5) / 0.5 = 2 * input - 1.

So black maps to -1, white to 1, and mid-grey sits at 0. It's the polar opposite of normalizing away from ComfyUI's convention - it's the most common case where a model genuinely doesn't want ComfyUI's [0, 1] tensor at all.

When you'll actually use it

Honestly, fewer people need this node than installed it. It matters when you're wiring a real GAN-style model into a ComfyUI graph - a face enhancer, a style transfer network, an old Pix2Pix-style checkpoint, anything whose documentation says input in [-1, 1] or whose output head is a tanh. Outside the ComfyUI ecosystem these models are everywhere; inside it, they're the edge case, which is exactly why the normalization family in this pack exists. The node is one input, one output, no knobs - the fixed recipe (x - 0.5) / 0.5, applied per channel.

The sibling [-0.5, 0.5] node is the same idea without the stretch: it only subtracts 0.5 and leaves the scale alone. If a model card says [-1, 1], use this one - the two are not interchangeable, and the difference (a factor of two on the input magnitude) is enough to shift results.

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. It's under image/normalization, no extra dependencies.

Notes

Same preview warning as every normalize node: after this, pixels go negative, and a preview node will show you a dark mess. That's correct behavior for the model, not a bug. If you need to convert back to [0, 1] afterward, the math is (x + 1) / 2 - the pack doesn't ship a reverse node, so you'll do that with a math node or just let the model's own output handle the round trip. And if the model you're feeding doesn't specifically want [-1, 1], skip this node - normalizing without a reason is how you get silent quality loss and confusing debugging sessions.

Categoryimage/normalization

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
imageIMAGE