Nodes/ComfyUI-ClipScore-Nodes/Fake Image Processor
ComfyUI Node

Fake Image Processor

Score your generations against a reference

By azure-dragon-ai·Created 3 years ago·Updated 2 years ago· 4
Fake Image Processor
  • model
  • processor
  • images
  • FAKE_FEATURES
device

The Fake Image Processor (HaojihuiClipScoreFakeImageProcessor) is the "generated image" side of this pack's scoring pipeline. The naming is playful - "fake" here just means "not the reference." You hook up the image your diffusion model produced, it converts that image into CLIP features, and those features become the fake_features input that the ImageScore node compares against the "real" reference.

It's the twin of the Real Image Processor. Same inputs, same code path, different output type so the scorer knows which side is which. If you're evaluating whether a batch of generations matches a target look, the graph you want is: Loader → Real Image Processor (your reference) → ImageScore, and Loader → Fake Image Processor (your generation) → ImageScore. The score you get out is a CLIP-space similarity - higher means the generation sits closer to the reference in what CLIP thinks is meaningful.

How it works

The mechanism is the same as every processor in this pack: take the first image of the incoming IMAGE tensor, run it through the PROCESSOR from the Loader (the resize, center-crop, normalize step), and encode it:

img = processor(image)
features = model.encode_image(img.to(device))
return (features,)

The distinguishing bit is the output type - FAKE_FEATURES - which is what ImageScore's fake_features socket expects. That's the entire difference between this node and its "real" twin: the label on the wire.

The inputs that matter

  • images - the IMAGE tensor of your generated image. Wire it off your VAE decode, or LoadImage if you're testing existing files.
  • model / processor - both come from the pack's Loader node. There's no way around running the Loader first; these sockets are typed to its PS_MODEL / PS_PROCESSOR outputs.
  • device - cuda or cpu.

One output: FAKE_FEATURES, straight into ImageScore.

Gotchas

The batch limitation again, and it's worth repeating loudly because it will confuse you the first time: this node only processes images[0]. Throw a batch of ten generations at it and nine get ignored. If you want a per-image score across a set, you need to process them one at a time - which, combined with the pack's broken scorer (see the ImageScore article), makes this more of a learning toy than a batch evaluation tool.

Also worth knowing before you invest an afternoon: the score this feeds is image-to-image similarity, not a quality metric. CLIP was trained to align images with text, so it's decent at "does this picture contain the same stuff as that picture" and weak at "is this picture good." Two images that both have a red car and a sunset will score high even if one is a masterpiece and the other is a smeared mess. Use it as a consistency check, not a taste judge.

Installing

Standard for this pack: ComfyUI Manager (search "ComfyUI-ClipScore-Nodes"), or clone it into custom_nodes and restart:

cd ComfyUI/custom_nodes
git clone https://github.com/azure-dragon-ai/ComfyUI-ClipScore-Nodes

Because the pack ships no requirements.txt, you have to install OpenAI's clip package yourself:

pip install git+https://github.com/openai/CLIP.git

And run the Loader once first - that's what downloads the CLIP weights from OpenAI. Miss the pip step and ComfyUI will greet you with No module named 'clip'.

Final word: this pack is a tiny, unmaintained January 2024 project. It's fine for messing around with CLIP-based comparison; it's not something to stake a serious workflow on.

CategoryHaojihui/ClipScore

Inputs (4)

NameTypeDefaultDescription
modelPS_MODEL
processorPS_PROCESSOR
deviceCOMBO2 options: cuda, cpu
imagesIMAGE

Outputs (1)

NameTypeDescription
FAKE_FEATURESFAKE_FEATURES