MCPcopy Create free account
hub / github.com/OpenTalker/StyleHEAT / _compute_binary_kernel

Function _compute_binary_kernel

third_part/decalib/utils/util.py:380–388  ·  view source on GitHub ↗

r"""Creates a binary kernel to extract the patches. If the window size is HxW will create a (H*W)xHxW kernel.

(window_size)

Source from the content-addressed store, hash-verified

378 return F.conv2d(x, kernel, padding=padding, stride=1, groups=c)
379
380def _compute_binary_kernel(window_size):
381 r"""Creates a binary kernel to extract the patches. If the window size
382 is HxW will create a (H*W)xHxW kernel.
383 """
384 window_range = window_size[0] * window_size[1]
385 kernel: torch.Tensor = torch.zeros(window_range, window_range)
386 for i in range(window_range):
387 kernel[i, i] += 1.0
388 return kernel.view(window_range, 1, window_size[0], window_size[1])
389
390def median_blur(x, kernel_size=(3,3)):
391 b, c, h, w = x.shape

Callers 1

median_blurFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected