Flow is represented as difference between two coordinate grids flow = coords1 - coords0
(self, img)
| 68 | m.eval() |
| 69 | |
| 70 | def initialize_flow(self, img): |
| 71 | """ Flow is represented as difference between two coordinate grids flow = coords1 - coords0""" |
| 72 | N, C, H, W = img.shape |
| 73 | coords0 = coords_grid(N, H // 8, W // 8, img.device) |
| 74 | coords1 = coords_grid(N, H // 8, W // 8, img.device) |
| 75 | |
| 76 | # optical flow computed as difference: flow = coords1 - coords0 |
| 77 | return coords0, coords1 |
| 78 | |
| 79 | def upsample_flow(self, flow, mask): |
| 80 | """ Upsample flow field [H/8, W/8, 2] -> [H, W, 2] using convex combination """ |