MCPcopy Create free account
hub / github.com/apple/ml-4m / fn

Method fn

fourm/data/modality_transforms.py:429–445  ·  view source on GitHub ↗
(x, xn)

Source from the content-addressed store, hash-verified

427 p = crop_points[:,0]
428 p_next = np.roll(p, (-1), axis=(0))
429 def fn(x, xn):
430 output = []
431 c_diff = p_next - p
432 x_diff = x - xn
433 for diff, c in zip(c_diff, p):
434 A = np.array([
435 [diff[0], x_diff[0]],
436 [diff[1], x_diff[1]]
437 ])
438 b = x - c
439 try:
440 lmbda = np.linalg.solve(A, b)
441 if 0 <= lmbda[0] <= 1 and 0 <= lmbda[1] <= 1:
442 output.append(lmbda[1] * xn + (1-lmbda[1]) * x)
443 except:
444 continue
445 return output
446 return fn
447
448 def crop_sample(self, sample, crop_coords):

Callers 1

forwardMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected