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