Nodes/MKRShift_Nodes/Batch Difference Preview
ComfyUI Node

Batch Difference Preview

A/B two batches and see the diff, not just the pair

By criskb·Created 7 months ago·Updated 5 months ago· 0
Batch Difference Preview
  • image_a
  • image_b
  • image_out
  • difference_preview
  • layout_json
columns0
layout_modeA | B | Diff
difference_styleheat
difference_gain2.00
tile_fit_modecontain
panel_padding14
panel_gap18
label_height44
show_resolutiontrue
themedark
max_collage_side0

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; gray renders 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.

CategoryMKRShift Nodes/Inspect/Compare

Inputs (13)

NameTypeDefaultDescription
image_aIMAGE
image_bIMAGE
columnsoptINT00–32
layout_modeoptCOMBOA | B | Diff3 options: A | B | Diff, A | Diff, Diff Only
difference_styleoptCOMBOheat2 options: heat, gray
difference_gainoptFLOAT2.000.1–8
tile_fit_modeoptCOMBOcontain3 options: contain, crop, stretch
panel_paddingoptINT144–96
panel_gapoptINT180–128
label_heightoptINT4420–160
show_resolutionoptBOOLEANtrue
themeoptCOMBOdark3 options: dark, light, studio
max_collage_sideoptINT00–32768

Outputs (3)

NameTypeDescription
image_outIMAGE
difference_previewIMAGE
layout_jsonSTRING