MCPcopy Create free account
hub / github.com/Francis-Rings/StableAnimator / _gaussian

Function _gaussian

train.py:303–317  ·  view source on GitHub ↗
(window_size: int, sigma)

Source from the content-addressed store, hash-verified

301
302
303def _gaussian(window_size: int, sigma):
304 if isinstance(sigma, float):
305 sigma = torch.tensor([[sigma]])
306
307 batch_size = sigma.shape[0]
308
309 x = (torch.arange(window_size, device=sigma.device,
310 dtype=sigma.dtype) - window_size // 2).expand(batch_size, -1)
311
312 if window_size % 2 == 0:
313 x = x + 0.5
314
315 gauss = torch.exp(-x.pow(2.0) / (2 * sigma.pow(2.0)))
316
317 return gauss / gauss.sum(-1, keepdim=True)
318
319
320def _gaussian_blur2d(input, kernel_size, sigma):

Callers 1

_gaussian_blur2dFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected