ComfyUI Node

Apply Circular Padding VAE

Wrap padding on encode and decode

By cedarconnor·Created about a year ago·Updated 7 months ago· 2
Apply Circular Padding VAE
  • vae
  • vae
inplacetrue
x_axis_onlytrue

The UNet isn't the only neural network that sees the panorama as a flat image. The VAE's encoder and decoder use the same convolution layers, with the same zero-padding at the left and right edges - which means seam artifacts get baked in at the encode/decode stage too. Apply Circular Padding VAE is the VAE's half of the same fix the Model node applies to the UNet: make the convolution padding wrap horizontally so the VAE treats the image as a cylinder.

In practice you use the two together. A "seam-safe generation" pipeline looks like: apply circular padding to the model and to the VAE, then run your panorama through VAE Encode → KSampler → VAE Decode as usual. Both networks are now wrap-aware, so neither one introduces its own vertical seam at the wrap point. The README's framing is "reduce seam artifacts"; the pair is the pack's answer to "I want to generate 360° content directly, not just patch it afterward."

How it works

It's the same code path as the Model variant: the node walks every Conv2d layer in the VAE and swaps in a circular-x padding forward pass (x_axis_only on) or applies PyTorch's native circular padding on both axes (off). The inplace toggle has the same semantics, and the same gotcha: default is inplace: true, which mutates the loaded VAE object in memory. The only way to restore the original padding is to reload the VAE - the node's tooltip says it plainly: "reload to undo if applied inplace."

Inputs and outputs

  • vae (required) - a VAE from any VAE loader.
  • inplace (default true) - mutate the loaded VAE, or deepcopy it first.
  • x_axis_only (default true) - wrap horizontally only (right for equirectangular), or both axes.

Output is a vae, same type in and out, ready for VAE Encode / Decode.

Installing it

Part of the LatLong pack - Manager search "LatLong", or:

cd ComfyUI/custom_nodes
git clone https://github.com/cedarconnor/comfyui-LatLong
cd comfyui-LatLong
pip install -r requirements.txt

Restart ComfyUI. Under LatLong/Models. Deps: numpy, opencv-python, scipy, torch, Pillow; no model files.

Gotchas

Two things worth flagging. First, inplace on a VAE is scarier than on a model in one specific way: a VAE is shared across whatever else you're doing - an upscale workflow, a different image's encode - and a mutated VAE with circular padding will silently change those results too. It's a "reload when you're done" node, not a "set and forget" node. Second, don't expect this to carry the whole seam story alone. The VAE padding helps the encode/decode path, but the sampler's outputs still need the model-side padding, and real content mismatches at the seam still want the mask + inpaint workflow. This is one layer of a three-layer defense, not the whole defense.

CategoryLatLong/Models

Inputs (3)

NameTypeDefaultDescription
vaeVAEVAE to add circular x-axis Conv2d padding to.
inplaceBOOLEANtrueModify the loaded VAE (True) or a copy (False). If True, reload VAE to restore original padding.
x_axis_onlyBOOLEANtrueApply circular padding only on x-axis (recommended) or on both axes.

Outputs (1)

NameTypeDescription
vaeVAE