Skip to content

Fix ImportError: kornia removed pad re-export from geometry.transform.pyramid#516

Open
Vivi (VixenVillainous) wants to merge 1 commit into
Lightricks:masterfrom
VixenVillainous:fix-kornia-pad
Open

Fix ImportError: kornia removed pad re-export from geometry.transform.pyramid#516
Vivi (VixenVillainous) wants to merge 1 commit into
Lightricks:masterfrom
VixenVillainous:fix-kornia-pad

Conversation

@VixenVillainous

Copy link
Copy Markdown

Fixes #494

Problem

pyramid_blending.py imports pad from kornia.geometry.transform.pyramid:

from kornia.geometry.transform.pyramid import (
    ...
    pad,
)

Recent versions of kornia no longer re-export pad from that module, so the
import fails and the entire node pack fails to load with:

ImportError: cannot import name 'pad' from 'kornia.geometry.transform.pyramid'

This breaks LTXVideo for anyone on a current kornia build.

Fix

That pad was only ever a re-export of torch.nn.functional.pad. The module
already imports torch.nn.functional as F and uses torch.nn.functional.pad
directly elsewhere in the same file, so the swap is behavior-identical:

  • Removed pad from the kornia import block.
  • Replaced the two bare pad(...) calls with F.pad(...) in
    _pad_for_laplacian and _gaussian_pyramid.

No functional change — F.pad and the old kornia pad are the same function
with the same signature. Tested locally; node imports and runs cleanly.

@VixenVillainous

Copy link
Copy Markdown
Author

Quick context for reviewers: this is a one-line-equivalent fix for the
ImportError: cannot import name 'pad' that #494 reports. kornia 0.8.3
dropped the pad re-export from kornia.geometry.transform.pyramid, which
takes down the whole node pack on import.

Since that pad was just torch.nn.functional.pad (already imported as F
in this file), I swapped the two calls over to F.pad. No behavior change —
same function, same signature.

Tested locally on a current ComfyUI portable build (Python 3.13.12, kornia
0.8.3): the node imports and runs cleanly after the change. Happy to adjust
style if you'd prefer the calls spelled out as torch.nn.functional.pad for
consistency with line ~143.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot import name 'pad'

1 participant