(input)
| 18 | |
| 19 | |
| 20 | def downsample(input): |
| 21 | if input.size(0) % 2 == 1: |
| 22 | input = torch.cat((input, torch.unsqueeze(input[-1, :], 0)), dim=0) |
| 23 | if input.size(1) % 2 == 1: |
| 24 | input = torch.cat((input, torch.unsqueeze(input[:, -1], 1)), dim=1) |
| 25 | return ( |
| 26 | input[0::2, 0::2, :] |
| 27 | + input[1::2, 0::2, :] |
| 28 | + input[0::2, 1::2, :] |
| 29 | + input[1::2, 1::2, :] |
| 30 | ) * 0.25 |
| 31 | |
| 32 | |
| 33 | def build_pyramid(img): |