ComfyUI Node

Clip_Score

Did your image actually match the prompt? Clip_Score gives you the number

By wu12023·Created 2 years ago·Updated 2 years ago· 9
Clip_Score
  • Source_Image
  • Target_Image
  • Clip_Text_Score
  • Clip_Image_Score
Clip_Model
Target_Prompt

You've got a prompt and a generated image, and you're not sure whether the image actually says what the prompt said. Eyeballing gets you nowhere across a hundred-seed sweep. Clip_Score turns that gut check into a number: it measures how well your image matches a prompt (or a second image) in CLIP space, so you can rank candidates instead of squinting at them.

It comes from wu12023/ComfyUI-Image-Evaluation, a tiny pack by Yujia Wu that ships exactly two nodes - this one and Dino_Score. It's the sort of utility that lives quietly in a workflow: nothing here generates pixels, it just grades them. The name is a lie in the best way - no API calls, no keys, everything runs through a CLIP model pulled from Hugging Face.

How it works

CLIP was trained to pull images and text captions into one shared embedding space, which is exactly why it's the connective tissue of the whole image-generation stack. This node exploits that: it loads a CLIP model, embeds your Source_Image, then computes cosine similarity against either a text prompt or a second image. The closer the embeddings, the higher the score.

You pick the model from the Clip_Model dropdown, and the three choices are the same Hugging Face checkpoints CLIP is famous for:

  • openai/clip-vit-large-patch14 - the default and the one you want if accuracy matters. Heaviest download (~1GB), but notably better at catching misses.
  • openai/clip-vit-base-patch16 / openai/clip-vit-base-patch32 - lighter and faster, noticeably less picky.

The image-vs-image half runs raw cosine similarity on the CLIP image embeddings. The image-vs-prompt half goes through torchmetrics' CLIPScore, the standard metric used in the CLIP literature. Both come out as STRING outputs, not numbers - so if you want to feed the value into an expression or comparison node, you'll be parsing that string first.

The inputs that matter

Only three things to touch:

  • Source_Image - your generated (or candidate) image. Required.
  • Clip_Model - the CLIP variant, described above.
  • Target_Image or Target_Prompt - at least one. Wire a prompt to get Clip_Text_Score, an image to get Clip_Image_Score, or both to get both. Leave one unwired and it comes back as the string "None".

Installation

Same as any custom node:

cd ComfyUI/custom_nodes
git clone https://github.com/wu12023/ComfyUI-Image-Evaluation
cd ComfyUI-Image-Evaluation
pip install -r requirements.txt

Restart ComfyUI after. Or just search ComfyUI-Image-Evaluation in ComfyUI Manager and hit install. The requirements.txt is a single line - torchmetrics - because everything else (transformers, torchvision, Pillow, numpy) is already in a stock ComfyUI environment. The real install cost is the model: the first run downloads the CLIP checkpoint from Hugging Face, so don't panic when a run sits there "loading" for a minute on a fresh setup.

Where people get burned

Two things catch beginners. First, the model reloads from Hugging Face's local cache on every execution - the node has no model caching of its own, so each run re-reads the checkpoint off disk. On a 200-seed sweep that adds up, and it's purely this pack's lack of caching, not your setup. Second, treat the score as a ranking tool, not a truth meter. CLIP aligns with human taste imperfectly and tends to reward certain styles over others - a 0.28 for one prompt means nothing in absolute terms. Only compare scores across runs of the same prompt. If the import of CLIPScore errors out, pip install torchmetrics[multimodal] covers the extra dependency group.

CategoryImage_Evaluation

Inputs (4)

NameTypeDefaultDescription
Source_ImageIMAGE
Clip_ModelCOMBO3 options: openai/clip-vit-large-patch14, openai/clip-vit-base-patch16, openai/clip-vit-base-patch32
Target_ImageoptIMAGE
Target_PromptoptSTRING

Outputs (2)

NameTypeDescription
Clip_Text_ScoreSTRING
Clip_Image_ScoreSTRING