MCPcopy
hub / github.com/Rudrabha/Wav2Lip / transform

Function transform

face_detection/utils.py:56–89  ·  view source on GitHub ↗

Generate and affine transformation matrix. Given a set of points, a center, a scale and a targer resolution, the function generates and affine transformation matrix. If invert is ``True`` it will produce the inverse transformation. Arguments: point {torch.tensor} -- the inp

(point, center, scale, resolution, invert=False)

Source from the content-addressed store, hash-verified

54
55
56def transform(point, center, scale, resolution, invert=False):
57 """Generate and affine transformation matrix.
58
59 Given a set of points, a center, a scale and a targer resolution, the
60 function generates and affine transformation matrix. If invert is ``True``
61 it will produce the inverse transformation.
62
63 Arguments:
64 point {torch.tensor} -- the input 2D point
65 center {torch.tensor or numpy.array} -- the center around which to perform the transformations
66 scale {float} -- the scale of the face/object
67 resolution {float} -- the output resolution
68
69 Keyword Arguments:
70 invert {bool} -- define wherever the function should produce the direct or the
71 inverse transformation matrix (default: {False})
72 """
73 _pt = torch.ones(3)
74 _pt[0] = point[0]
75 _pt[1] = point[1]
76
77 h = 200.0 * scale
78 t = torch.eye(3)
79 t[0, 0] = resolution / h
80 t[1, 1] = resolution / h
81 t[0, 2] = resolution * (-center[0] / h + 0.5)
82 t[1, 2] = resolution * (-center[1] / h + 0.5)
83
84 if invert:
85 t = torch.inverse(t)
86
87 new_point = (torch.matmul(t, _pt))[0:2]
88
89 return new_point.int()
90
91
92def crop(image, center, scale, resolution=256.0):

Callers 3

cropFunction · 0.85
get_preds_fromhmFunction · 0.85
get_preds_fromhm_batchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected