Batch Difference Preview
A/B two batches and see the diff, not just the pair
- image_a
- image_b
- image_out
- difference_preview
- layout_json
Side-by-side A/B comparison has a flaw: your eyes glaze over when the two images are 95% identical. MKRBatchDifferencePreview fixes that by computing the difference - a heatmap of exactly where the two images diverge - and showing it as a third panel next to A and B. It's the comparison view for people who are actually iterating: change a LoRA weight, rerun, and instantly see which pixels moved instead of hunting for them.
It's part of the Inspect/Compare branch of MKRShift_Nodes, the same family as the collage preview, and it's built for batch work: both inputs take full batches, and it pairs them up frame by frame (a 10-image batch on both sides gives you 10 comparison rows).
How it works
Both batches are converted to PIL frames and paired by index (the shorter batch wins; a warning lands in the output if the counts differ). Each pair becomes one panel containing up to three tiles:
- A and B - the two originals, fitted into uniform slots.
- DIFF - the difference image: per-pixel absolute difference between A and B. With
difference_style = heat, the diff is rendered as a bright heat map where hotter color = more change;grayrenders it as plain intensity.difference_gain(default 2.0) amplifies the diff before rendering - the default already exaggerates, because raw pixel deltas are usually invisible to the eye.
layout_mode lets you trim the sheet: A | B | Diff (all three), A | Diff (drop B when A is the "before" and you know what it looks like), or Diff Only (just the change map - great for scanning a big batch for which one actually changed). Panels are arranged in a grid with your chosen columns, gaps, label strips, and a dark/light/studio theme.
Outputs: image_out (image_a, passed through), difference_preview (the sheet - wire to Preview Image), and layout_json.
Inputs that matter
image_a,image_b- the two batches. Both required.layout_mode- how many tiles per panel.difference_style/difference_gain- how the diff is rendered and amplified.columns- rows-per-panel layout; 0 auto-selects.tile_fit_mode- contain/crop/stretch for fitting mismatched sizes into the slots.max_collage_side- cap for huge sheets.
Install
ComfyUI Manager (search "MKRShift Nodes"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes
Restart. No extra dependencies, no models - pure numpy/PIL math.
Common issues
The big one is alignment. The diff is pixel-wise, so if A and B are different resolutions or one is shifted by even a couple of pixels, the entire image lights up as "different" and the map is useless. Normalize both batches to the same resolution before comparing (the pack's AdvResize or core resize handles this). Second, if the diff looks like noise, difference_gain is too high - the default 2.0 exaggerates a lot; drop toward 1.0 when comparing near-identical frames. And remember the comparison is per-pixel, not perceptual: a global brightness change reads as a solid wash even though "nothing changed" visually. It's a tool for spotting where, not for judging whether.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| image_a | IMAGE | — | |
| image_b | IMAGE | — | |
| columnsopt | INT | 00–32 | — |
| layout_modeopt | COMBO | A | B | Diff | 3 options: A | B | Diff, A | Diff, Diff Only |
| difference_styleopt | COMBO | heat | 2 options: heat, gray |
| difference_gainopt | FLOAT | 2.000.1–8 | — |
| tile_fit_modeopt | COMBO | contain | 3 options: contain, crop, stretch |
| panel_paddingopt | INT | 144–96 | — |
| panel_gapopt | INT | 180–128 | — |
| label_heightopt | INT | 4420–160 | — |
| show_resolutionopt | BOOLEAN | true | — |
| themeopt | COMBO | dark | 3 options: dark, light, studio |
| max_collage_sideopt | INT | 00–32768 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image_out | IMAGE | — |
| difference_preview | IMAGE | — |
| layout_json | STRING | — |