AItool commited on
Commit
31dac42
·
verified ·
1 Parent(s): 0d93a7f

Delete train_log/warplayer.py

Browse files
Files changed (1) hide show
  1. train_log/warplayer.py +0 -22
train_log/warplayer.py DELETED
@@ -1,22 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
-
4
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5
- backwarp_tenGrid = {}
6
-
7
-
8
- def warp(tenInput, tenFlow):
9
- k = (str(tenFlow.device), str(tenFlow.size()))
10
- if k not in backwarp_tenGrid:
11
- tenHorizontal = torch.linspace(-1.0, 1.0, tenFlow.shape[3], device=device).view(
12
- 1, 1, 1, tenFlow.shape[3]).expand(tenFlow.shape[0], -1, tenFlow.shape[2], -1)
13
- tenVertical = torch.linspace(-1.0, 1.0, tenFlow.shape[2], device=device).view(
14
- 1, 1, tenFlow.shape[2], 1).expand(tenFlow.shape[0], -1, -1, tenFlow.shape[3])
15
- backwarp_tenGrid[k] = torch.cat(
16
- [tenHorizontal, tenVertical], 1).to(device)
17
-
18
- tenFlow = torch.cat([tenFlow[:, 0:1, :, :] / ((tenInput.shape[3] - 1.0) / 2.0),
19
- tenFlow[:, 1:2, :, :] / ((tenInput.shape[2] - 1.0) / 2.0)], 1)
20
-
21
- g = (backwarp_tenGrid[k] + tenFlow).permute(0, 2, 3, 1)
22
- return torch.nn.functional.grid_sample(input=tenInput, grid=g, mode='bilinear', padding_mode='border', align_corners=True)