Image Reward
Rank a whole batch by what humans actually preferred (no API, no key)
- images
- score
- images
Stop eyeballing the grid; make it sort itself
The "Image Reward" node is a grader, not a generator. You feed it a prompt and a pile of images - say, every seed from a variation grid - and it scores each image for how well a human would prefer it for that prompt, sorts them best-first, and hands back the winners. It wraps THUDM's ImageReward, the NeurIPS 2023 human-preference reward model, trained on ~137,000 comparison pairs from ImageRewardDB.
The name is a small lie: nothing about this calls an API or needs a key. It's a local model, the whole thing runs on your machine.
What it's actually for
Batch triage. ComfyUI makes it trivial to dump 200 images in one run and then spend twenty minutes squinting at thumbnails. This node does the squinting for you - it ranks the batch and outputs only the top K. It's the ComfyUI-native equivalent of the folder-scoring apps people build when they get sick of culling output folders by hand.
Two things to keep straight before you use it. First, the score is prompt-conditional: it measures alignment with the prompt (plus general human preference), not absolute beauty. Second, it's a post-generation tool. Wire it after your sampler/VAE decode, not into it.
How it works
ImageReward is a BLIP-pretrain backbone - a ViT-Large image encoder cross-attending with a BERT text encoder - feeding a 768-dim MLP head that predicts the reward. The output is normalized (the code subtracts a mean and divides by a std) so scores sit roughly in the −1…+1 band. Higher is better. Don't over-read the absolute number; it's a within-model ranking signal, not a universal quality meter.
The node itself is lazy and VRAM-polite: the model loads on the first run from ComfyUI/models/image_reward/, gets moved to GPU, and is parked back on CPU after each batch. Later batches reuse it. Each image scores sequentially with a ComfyUI progress bar, so a big batch is a few moments, not instant.
Inputs and outputs that matter
You set two things and hand it a batch:
- prompt - the prompt those images were generated with. Multiline; it's the reference the model ranks against.
- topK - how many best images to keep. Default 3, range 1–500.
- images - the batch. Catch: this node expects an IMAGE list, not a raw batched tensor, so feed it from the pack's sibling "Image Batch To List" node (or anything else that emits a list).
Outputs: score (a STRING - the per-image scores, newline-joined, best first) and images (the top-K winners, sorted best first, ready to wire into a preview/save node). One gotcha beginners hit: score is a string, not a number, so you can't feed it into math or compare nodes - it's for display and logging, not computation.
Installing it
ComfyUI Manager is the easy route: search the pack title "comfyui-Image-reward" and install. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/shadowcz007/comfyui-Image-reward
then restart ComfyUI and let it install requirements.txt (openai-clip, timm==0.6.13, fairscale==0.4.13).
The real chore is models - three pieces, all of which must land in ComfyUI/models/image_reward/:
ComfyUI/models/image_reward/ImageReward.pt
ComfyUI/models/image_reward/med_config.json
ComfyUI/models/image_reward/bert-base-uncased/
That's a couple of gigabytes total, and the bert-base-uncased folder is the one people forget. If the node errors on first run with a model-load failure, you almost certainly missed it.
Common issues
- Model-load error on first run - missing
bert-base-uncased/. Grab it from Hugging Face'sgoogle-bert/bert-base-uncasedand put the folder undermodels/image_reward/. - Dependency clashes -
timm==0.6.13andfairscale==0.4.13are old, hard pins. If another custom node wants a newer timm, they'll fight; you may need to pick a winner or isolate envs. - "Wrong input type" feeding it a batch - remember it wants a list, hence the sibling "Image Batch To List" node.
- First run feels frozen - it's not; the model is loading, and each image scores in sequence.
The honest take
This pack is a 2024-era Mixlab-ecosystem side project that the community has mostly stopped talking about - it still works, but don't expect updates. It's also the rare node that does something genuinely missing from a stock ComfyUI install: a human-preference number on your outputs. If you run big variation grids and dread the cull, it's worth the install. If you generate one image at a time, skip it - you'd be adding two gigabytes of models to solve a problem you don't have.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| topK | INT | 31–500 | — |
| images | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| score | STRING | — |
| images | IMAGE | — |