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

Function _compute_padding

train.py:255–275  ·  view source on GitHub ↗

Compute padding tuple.

(kernel_size)

Source from the content-addressed store, hash-verified

253
254
255def _compute_padding(kernel_size):
256 """Compute padding tuple."""
257 # 4 or 6 ints: (padding_left, padding_right,padding_top,padding_bottom)
258 # https://pytorch.org/docs/stable/nn.html#torch.nn.functional.pad
259 if len(kernel_size) < 2:
260 raise AssertionError(kernel_size)
261 computed = [k - 1 for k in kernel_size]
262
263 # for even kernels we need to do asymmetric padding :(
264 out_padding = 2 * len(kernel_size) * [0]
265
266 for i in range(len(kernel_size)):
267 computed_tmp = computed[-(i + 1)]
268
269 pad_front = computed_tmp // 2
270 pad_rear = computed_tmp - pad_front
271
272 out_padding[2 * i + 0] = pad_front
273 out_padding[2 * i + 1] = pad_rear
274
275 return out_padding
276
277
278def _filter2d(input, kernel):

Callers 1

_filter2dFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected