KJNodes/latentsgenerated

Latent Patch Grid Remove KJ(LatentPatchGridRemoveKJ)

Latent Patch Grid Remove KJ removes the fixed offset that some DiTs leave at each position inside their patch_size x patch_size latent patches, a behavior seen with Ming-Image.

Latent Patch Grid Remove KJ

samples
LATENT
patch_size
2
KJNodes

Description

Latent Patch Grid Remove KJ removes the fixed offset that some DiTs leave at each position inside their patch_size x patch_size latent patches, a behavior seen with Ming-Image. After VAE decode, this offset shows up as a faint grid over flat colors. For example, with patch_size set to 2 and an 8x VAE, the grid repeats every 16 px.

The node estimates the offset per image, frame, and channel from the whole latent, then subtracts it. Because the correction is estimated globally rather than filtered spatially, detail is not blurred. Busy, detailed images typically see little change.

Inputs

samples

  • Type: LATENT
  • Required: Yes

The latent samples to correct. Connect the sampler output here, then connect this node's output to VAE Decode.

patch_size

  • Type: INT
  • Required: Yes
  • Default: 2
  • Minimum: 2
  • Maximum: 8

The spatial patch size of the diffusion model. Use 2 for most DiTs. This value controls the size of the latent patch grid whose per-position offset is estimated and removed, so it should match the patch size used by the model that produced the latent.

Outputs

LATENT

The corrected latent, with the fixed patch-position offset subtracted. Connect this output to VAE Decode.

Usage Notes

  • Place this node between the sampler and VAE Decode.
  • Set patch_size to the spatial patch size of the diffusion model. Most DiTs use 2.
  • The offset is estimated per image, frame, and channel from the whole latent and then subtracted, which avoids blurring detail.
  • The correction targets grid artifacts that become visible after VAE decode. With patch_size 2 and an 8x VAE, the visible grid spacing is 16 px.
  • Busy, detailed images usually see little change. The effect is most noticeable on flat colors and similar low-detail regions.

Comments

Sign in with GitHub to join the discussion.

Loading comments…