MCPcopy
hub / github.com/alex-damian/pulse / __init__

Method __init__

bicubic.py:20–35  ·  view source on GitHub ↗
(self, factor=4, cuda=True, padding='reflect')

Source from the content-addressed store, hash-verified

18 return 0.0
19
20 def __init__(self, factor=4, cuda=True, padding='reflect'):
21 super().__init__()
22 self.factor = factor
23 size = factor * 4
24 k = torch.tensor([self.bicubic_kernel((i - torch.floor(torch.tensor(size / 2)) + 0.5) / factor)
25 for i in range(size)], dtype=torch.float32)
26 k = k / torch.sum(k)
27 # k = torch.einsum('i,j->ij', (k, k))
28 k1 = torch.reshape(k, shape=(1, 1, size, 1))
29 self.k1 = torch.cat([k1, k1, k1], dim=0)
30 k2 = torch.reshape(k, shape=(1, 1, 1, size))
31 self.k2 = torch.cat([k2, k2, k2], dim=0)
32 self.cuda = '.cuda' if cuda else ''
33 self.padding = padding
34 for param in self.parameters():
35 param.requires_grad = False
36
37 def forward(self, x, nhwc=False, clip_round=False, byte_output=False):
38 # x = torch.from_numpy(x).type('torch.FloatTensor')

Callers

nothing calls this directly

Calls 1

bicubic_kernelMethod · 0.95

Tested by

no test coverage detected