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

Function _compute_padding

train_single.py:259–279  ·  view source on GitHub ↗

Compute padding tuple.

(kernel_size)

Source from the content-addressed store, hash-verified

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

Callers 1

_filter2dFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected