Nodes/ComfyUI_pytorch360convert/Apply Circular Padding Model
ComfyUI Node

Apply Circular Padding Model

Make the model itself think your pano wraps around — kill the seam at the source

By ProGamerGov·Created 2 years ago·Updated 11 months ago· 38
Apply Circular Padding Model
  • model
  • MODEL
inplacetrue
x_axis_onlytrue

Here's the deepest reason equirectangular generation has a seam: the neural network has no idea the image wraps around. Every Conv2d layer treats the left edge and the right edge as unrelated pixels, padding with zeros at the boundaries. But a panorama is a sphere - its left edge is its right edge. Apply Circular Padding Model fixes that at the architectural level: it rewrites every convolution in your model so the x-axis pads circularly, wrapping the tensor around instead of zero-padding. Your sampler then "sees" a seamless cylinder of pixels, and the pano it generates doesn't have a seam to begin with.

That's a genuinely different approach from the rest of the pack. Seam masks fix the output afterward; this node fixes the model so the output never has the problem. It's the one to reach for when you're generating 360s as a repeatable thing, not doing a one-off patch.

How it works

It walks every torch.nn.Conv2d layer in the model and swaps its padding behavior. With x_axis_only (default True) it patches the convolution's forward pass so horizontal padding wraps around, and leaves vertical padding alone - right, because in a panorama only the horizontal axis is periodic. If you set x_axis_only to False, it instead sets padding_mode = "circular" on the layers, which wraps both axes - that can be wrong for equirectangulars since the top and bottom are not continuous (they're the two poles), so leave it True unless you know why you're changing it.

Inputs:

  • model - any MODEL (a checkpoint loaded in ComfyUI).
  • inplace - modify the already-loaded model (True, default) or a copy (False). The tooltip is the warning: if True, "model will have to be reloaded to restore padding to the original values." In other words, once you patch it, every generation that session uses circular padding. That's usually what you want for a 360 workflow - but it means you should apply this node and then generate, and if you want the normal model back you must reload it.
  • x_axis_only - horizontal-only wrapping, default True.

Output is the MODEL, ready to wire into your sampler.

Where it bites

The classic gotcha is forgetting about inplace. Patch the model in place, generate, then later run a normal workflow in the same session expecting the vanilla model - it's still circular-padded, and unless your images happen to be panoramas you'll wonder why edges look weird. The False option (copy) is safer for experimentation; True is what you want when the model is dedicated to 360 work. Also worth knowing: circular padding on every conv adds a little compute, and some architectures with huge convolutions feel it more than others. It also doesn't magically fix everything - the model wasn't trained with circular padding, so the wrap is a strong prior, not a guarantee.

Install

Standard for the pack: ComfyUI Manager (search "ComfyUI_pytorch360convert") or git clone https://github.com/ProGamerGov/ComfyUI_pytorch360convert into ComfyUI/custom_nodes and restart. The requirements.txt is empty, so python -m pip install pytorch360convert is likely needed. No model downloads - this operates on whatever model you already have loaded.

Categorypytorch360convert/models

Inputs (3)

NameTypeDefaultDescription
modelMODELModel to add circular x-axis conv2d padding to.
inplaceBOOLEANtrueModify the already loaded model (True) or a copy of the model (False). If True, model 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
MODELMODEL