MCPcopy Create free account
hub / github.com/drinkingcoder/FlowFormer-Official / grid_transform

Method grid_transform

core/utils/flow_transforms.py:113–123  ·  view source on GitHub ↗
(self, meshgrid, t, normalize=True, gridsize=None)

Source from the content-addressed store, hash-verified

111 return result
112
113 def grid_transform(self, meshgrid, t, normalize=True, gridsize=None):
114 if gridsize is None:
115 h, w = meshgrid[0].shape
116 else:
117 h, w = gridsize
118 vgrid = torch.cat([(meshgrid[0] * t[0] + meshgrid[1] * t[2] + t[4])[:,:,np.newaxis],
119 (meshgrid[0] * t[1] + meshgrid[1] * t[3] + t[5])[:,:,np.newaxis]],-1)
120 if normalize:
121 vgrid[:,:,0] = 2.0*vgrid[:,:,0]/max(w-1,1)-1.0
122 vgrid[:,:,1] = 2.0*vgrid[:,:,1]/max(h-1,1)-1.0
123 return vgrid
124
125
126 def __call__(self, inputs, target):

Callers 1

__call__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected