Nodes/ComfyUI_pytorch360convert/Apply Circular Padding VAE
ComfyUI Node

Apply Circular Padding VAE

Same seam-killing trick, applied to the VAE instead of the diffusion model

By ProGamerGov·Created 2 years ago·Updated 11 months ago· 37
Apply Circular Padding VAE
  • vae
  • VAE
inplacetrue
x_axis_onlytrue

The seam in a generated panorama isn't only the diffusion model's fault. The VAE encodes and decodes your image through its own stack of convolutions, and every one of those also treats the left and right edges of the image as separate. So even if you generated a seamless latent, the VAE's decoder can re-introduce a seam when it turns that latent back into pixels - the encoding and decoding stages are convolutions too, and they zero-pad at the boundary just like everything else.

Apply Circular Padding VAE is the VAE twin of Apply Circular Padding Model. Same idea, same controls, applied to the autoencoder instead of the denoiser. If you're doing serious 360 work, patching both is the full treatment - the model so the denoising happens in seamless space, and the VAE so the round trip through latent space doesn't reintroduce the boundary.

How it works

It finds every torch.nn.Conv2d in the VAE (specifically in its first_stage_model) and patches horizontal padding to wrap around. Same options as the model version:

  • vae - any VAE loaded in ComfyUI.
  • inplace - default True: modify the loaded VAE directly. As the tooltip warns, you'd have to reload the VAE to restore normal padding. Setting False deep-copies the VAE and patches the copy, at the cost of memory.
  • x_axis_only - default True: only the horizontal (wrap-around) axis gets circular padding, which is correct for equirectangulars. Set False and it wraps both axes, which is wrong for panoramas because the poles don't connect - leave it True.

Output is the patched VAE, ready to wire into your VAE Encode/Decode.

The honest caveat

Circular padding is a strong prior but not a miracle. Patching the VAE helps the latent↔pixel boundary behave like a wrapped sphere, but the model still wasn't trained with circular padding, so results can vary by checkpoint. If you patch the diffusion model and still see a faint seam in output, patching the VAE too is the natural next step - and if the seam persists, that's when you reach for the mask-and-inpaint approach (Create Seam Mask) as the reliable fallback. Think of the padding nodes as the "prevent" strategy and the mask nodes as the "repair" strategy; serious 360 pipelines often use both.

The biggest trap is the same one as the model version: forget about inplace and the VAE stays patched for the rest of the session. If a later non-360 workflow in the same run starts producing odd edge behavior, this is why - reload the VAE.

Install

Same pack, same install: ComfyUI Manager → "ComfyUI_pytorch360convert", or git clone https://github.com/ProGamerGov/ComfyUI_pytorch360convert into ComfyUI/custom_nodes and restart. The pack's requirements.txt is empty so you'll likely need python -m pip install pytorch360convert. No model downloads - it patches whatever VAE you feed it.

Categorypytorch360convert/models

Inputs (3)

NameTypeDefaultDescription
vaeVAEVAE to add circular x-axis conv2d padding to.
inplaceBOOLEANtrueModify the already loaded VAE (True) or a copy of the VAE (False). If True, VAE will have to be reloaded to restore padding to the original values. Modifying inplace will use less memory.
x_axis_onlyBOOLEANtrueApply circular padding only to the x-axis or to both the x and y axes.

Outputs (1)

NameTypeDescription
VAEVAE