MCPcopy Create free account
hub / github.com/drinkingcoder/NeuralMarker / InputPadder

Class InputPadder

core/utils/utils.py:7–24  ·  view source on GitHub ↗

Pads images such that dimensions are divisible by 8

Source from the content-addressed store, hash-verified

5from core.utils.forward_warp import ForwardWarp
6
7class InputPadder:
8 """ Pads images such that dimensions are divisible by 8 """
9 def __init__(self, dims, mode='sintel'):
10 self.ht, self.wd = dims[-2:]
11 pad_ht = (((self.ht // 8) + 1) * 8 - self.ht) % 8
12 pad_wd = (((self.wd // 8) + 1) * 8 - self.wd) % 8
13 if mode == 'sintel':
14 self._pad = [pad_wd//2, pad_wd - pad_wd//2, pad_ht//2, pad_ht - pad_ht//2]
15 else:
16 self._pad = [pad_wd//2, pad_wd - pad_wd//2, 0, pad_ht]
17
18 def pad(self, *inputs):
19 return [F.pad(x, self._pad, mode='replicate') for x in inputs]
20
21 def unpad(self,x):
22 ht, wd = x.shape[-2:]
23 c = [self._pad[2], ht-self._pad[3], self._pad[0], wd-self._pad[1]]
24 return x[..., c[0]:c[1], c[2]:c[3]]
25
26def pytorch_foward_interpolate(flow):
27 def get_gaussian_weights(x, y, x1, x2, y1, y2):

Callers 1

estimateMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected