ComfyUI Node

Apply Circular Padding Model

Circular padding for seam-safe generation

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

Most of the pack fixes seams after the image exists - blend them, mask them, inpaint them. Apply Circular Padding Model tries a bolder idea: stop the seam from being created in the first place. It patches your diffusion model so its convolutions wrap around horizontally, treating the panorama as a cylinder instead of a flat image.

Here's the reasoning. When the UNet processes an equirectangular image, its convolution layers pad with zeros at the image edges - and in a panorama, the left and right edges are the same place in the world. So the model is being shown "nothing" at a spot where the scene actually continues, and it dutifully draws seam artifacts there. The fix: make the convolution padding circular on the horizontal axis, so features wrap from the right edge back to the left edge, the way the world actually does. The model stops seeing a cliff and starts seeing a seamless loop.

How it works

The node walks every Conv2d layer in the loaded model and swaps in a circular-padding forward pass. With x_axis_only on (the default, and what you want for equirectangular seams), only the horizontal padding wraps - vertical padding stays normal, since up and down are genuine edges in a panorama (they're the poles, not a wrap). Set x_axis_only off and it applies PyTorch's native circular padding mode to both axes.

The inplace toggle matters and is the thing to remember: on by default, it modifies the model object already loaded in memory. That's fast and cheap (no copy of a multi-GB model), but it means the same model object elsewhere in your graph is affected too, and the only way to undo it is to reload the model. Set inplace to false if you want a deepcopy - safe, but you just paid for a full model copy.

Inputs and outputs

  • model (required) - a MODEL from any checkpoint/UNET loader.
  • inplace (default true) - mutate the loaded model, or work on a copy.
  • x_axis_only (default true) - wrap only horizontally (recommended for equirectangular), or both axes.

Output is a model - the same MODEL type in, same out, ready to plug into KSampler like normal.

Installing it

Install the pack via 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. Node under LatLong/Models. Deps: numpy, opencv-python, scipy, torch, Pillow - no extra model files.

Gotchas

This is a niche node and it's honest about its limits. Circular padding reduces seam artifacts - it doesn't eliminate them, and it's no substitute for a seam mask + inpaint when the seam content is genuinely broken. The inplace behavior is the real trap: run it with inplace on, then use that model for a non-panorama image in the same session, and the wrap padding still applies (with x_axis_only off, both axes wrap, which is wrong for regular images). Treat it as a "configure then generate panorama" step, and reload the model when you're done with 360° work - the README's own advice is to reload to undo.

If this sounds like a lot of ceremony for a subtle gain, you're not wrong. Most people get 90% of the seam-free result from Edge Blender + seam inpainting alone. This node is for when you're doing a lot of direct 360° generation and want the model itself on your side.

CategoryLatLong/Models

Inputs (3)

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

Outputs (1)

NameTypeDescription
modelMODEL