MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / _wavelet_blur

Function _wavelet_blur

diffsynth/pipelines/flashvsr_tiny_long.py:55–63  ·  view source on GitHub ↗
(x: torch.Tensor, radius: int)

Source from the content-addressed store, hash-verified

53
54
55def _wavelet_blur(x: torch.Tensor, radius: int) -> torch.Tensor:
56 assert x.dim() == 4, 'x 必须是 (N, C, H, W)'
57 N, C, H, W = x.shape
58 base = _make_gaussian3x3_kernel(x.dtype, x.device)
59 weight = base.view(1, 1, 3, 3).repeat(C, 1, 1, 1)
60 pad = radius
61 x_pad = F.pad(x, (pad, pad, pad, pad), mode='replicate')
62 out = F.conv2d(x_pad, weight, bias=None, stride=1, padding=0, dilation=radius, groups=C)
63 return out
64
65
66def _wavelet_decompose(x: torch.Tensor, levels: int = 5) -> Tuple[torch.Tensor, torch.Tensor]:

Callers 1

_wavelet_decomposeFunction · 0.70

Calls 1

_make_gaussian3x3_kernelFunction · 0.70

Tested by

no test coverage detected