TBG SIFT+ Drift Correction
TBG SIFT+ Drift Correction
- image
- reference
- image
- info
Big tiled upscales have a quiet failure mode: every tile is fine on its own, but the image drifts. A face that should line up with the reference is half a tile off, or one tile's geometry has slowly rotated relative to its neighbor. That's geometric drift, and it's what this node is for. TBG SIFT+ Drift Correction detects small affine drift between an image and a reference using SIFT feature matching, then warps the image back into alignment. It's the standalone version of the exact same correction the TBG ETUR Refiner runs on every generated tile (the Scale-Invariant Feature Transform toggle in the Refiner), pulled out so you can fix drift anywhere - including outside the ETUR graph entirely.
The pack is by TBG (Tobias Laarmann), and this node is one of the "takeaway" utilities the 1.2 release extracted from the big ETUR refiner.
How it works
SIFT (Scale-Invariant Feature Transform) finds distinctive keypoints in an image that are robust to scale and rotation - corners, edges, texture blobs. The node runs SIFT on both the image and the reference, matches keypoints between them, and fits an affine transform (translation + rotation + slight scale/shear) to the matches. Then it warps the image by the inverse of that transform so it lines back up with the reference. That's the "SIFT+" in the name: the correction isn't just translation, it's the full affine fit.
Geometry_Drift_Correction (on by default) selects the correction path - the tooltip says "On uses the strongest x4 drift-correction path," i.e. the multi-scale variant that's more robust to large-ish offsets. Turning it off disables correction entirely, so the node becomes a no-op pass-through.
Inputs
- image - the image to correct. The tooltip is specific: it must match the reference size. If the two are different resolutions, SIFT matching gets confused and you'll get a wrong or rejected fit.
- reference - the image to align against. In the ETUR tiling world that's the original upscaled tile; outside ETUR, it's whatever "correct" version you're anchoring to.
- Geometry_Drift_Correction (on) - master switch for the correction path.
Outputs: the corrected image, plus an info JSON string describing what was detected and corrected - handy when you're debugging why a tile didn't line up (it reports the transform, and an empty/identity result tells you no drift was found).
Install
Part of the whole pack - and this is one node where the install actually matters, because SIFT lives in OpenCV's contrib modules:
cd ComfyUI/custom_nodes
git clone https://github.com/Ltamann/ComfyUI-TBG-ETUR
cd ComfyUI-TBG-ETUR && pip install -r requirements.txt
The requirements file installs both opencv-python and opencv-contrib-python - if you already have OpenCV installed and the node errors on import, the contrib package (which provides cv2.SIFT_create) is the usual culprit. ComfyUI Manager → "TBG Enhanced Upscaler" also works, then restart.
Common issues
- Node errors on SIFT import -
cv2.SIFT_createrequiresopencv-contrib-python. If your environment has a plainopencv-pythonwithout contrib, the node will fail to load.pip install opencv-contrib-pythonfixes it. - "Image must match the reference size" - size mismatch is the #1 cause of garbage results. Upscale the reference (or downscale the image) to the same dimensions first.
- Info says no drift detected but you know there is - SIFT needs texture. Flat, featureless regions (skies, walls, gradients) have no keypoints to match, so the fit silently fails. This is a fundamental SIFT limitation, not a node bug - add a featureful region or accept the limitation.
- Warped edges - after affine warping the image is cropped or has blank borders. That's expected for rotation correction; in the ETUR tiling workflow it's hidden by the tile fusion, which is why it's more visible when you use this standalone.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Image to correct. This must match the reference size. | |
| reference | IMAGE | Reference image used to detect and correct small SIFT+ affine drift. | |
| Geometry_Drift_Correction | BOOLEAN | true | Off disables it. On uses the strongest x4 drift-correction path. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| info | STRING | — |