(self, theta)
| 419 | self.grid_Y = self.grid_Y.cuda() |
| 420 | |
| 421 | def forward(self, theta): |
| 422 | b = theta.size(0) |
| 423 | if not theta.size() == (b, 6): |
| 424 | theta = theta.view(b, 6) |
| 425 | theta = theta.contiguous() |
| 426 | |
| 427 | t0 = theta[:, 0].unsqueeze(1).unsqueeze(2).unsqueeze(3) |
| 428 | t1 = theta[:, 1].unsqueeze(1).unsqueeze(2).unsqueeze(3) |
| 429 | t2 = theta[:, 2].unsqueeze(1).unsqueeze(2).unsqueeze(3) |
| 430 | t3 = theta[:, 3].unsqueeze(1).unsqueeze(2).unsqueeze(3) |
| 431 | t4 = theta[:, 4].unsqueeze(1).unsqueeze(2).unsqueeze(3) |
| 432 | t5 = theta[:, 5].unsqueeze(1).unsqueeze(2).unsqueeze(3) |
| 433 | |
| 434 | grid_X = expand_dim(self.grid_X, 0, b) |
| 435 | grid_Y = expand_dim(self.grid_Y, 0, b) |
| 436 | grid_Xp = grid_X * t0 + grid_Y * t1 + t2 |
| 437 | grid_Yp = grid_X * t3 + grid_Y * t4 + t5 |
| 438 | |
| 439 | return torch.cat((grid_Xp, grid_Yp), 3) |
| 440 | |
| 441 | |
| 442 | class HomographyGridGen(Module): |
nothing calls this directly
no test coverage detected