mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-08-22 06:23:20 -07:00
Images are in float32, not uint8, color value should be "1"
This commit is contained in:
parent
4eafd682d1
commit
e29a24c0da
1 changed files with 4 additions and 4 deletions
|
@ -116,7 +116,7 @@ def transform_points(points, mat, invert=False):
|
||||||
points = cv2.transform(points, mat, points.shape)
|
points = cv2.transform(points, mat, points.shape)
|
||||||
points = np.squeeze(points)
|
points = np.squeeze(points)
|
||||||
return points
|
return points
|
||||||
|
|
||||||
def get_transform_mat (image_landmarks, output_size, face_type, scale=1.0):
|
def get_transform_mat (image_landmarks, output_size, face_type, scale=1.0):
|
||||||
if not isinstance(image_landmarks, np.ndarray):
|
if not isinstance(image_landmarks, np.ndarray):
|
||||||
image_landmarks = np.array (image_landmarks)
|
image_landmarks = np.array (image_landmarks)
|
||||||
|
@ -142,7 +142,7 @@ def get_transform_mat (image_landmarks, output_size, face_type, scale=1.0):
|
||||||
if face_type == FaceType.FULL_NO_ALIGN:
|
if face_type == FaceType.FULL_NO_ALIGN:
|
||||||
face_type = FaceType.FULL
|
face_type = FaceType.FULL
|
||||||
remove_align = True
|
remove_align = True
|
||||||
|
|
||||||
if face_type == FaceType.HALF:
|
if face_type == FaceType.HALF:
|
||||||
padding = 0
|
padding = 0
|
||||||
elif face_type == FaceType.FULL:
|
elif face_type == FaceType.FULL:
|
||||||
|
@ -163,7 +163,7 @@ def get_transform_mat (image_landmarks, output_size, face_type, scale=1.0):
|
||||||
area = mathlib.polygon_area(bbox[:,0], bbox[:,1] )
|
area = mathlib.polygon_area(bbox[:,0], bbox[:,1] )
|
||||||
side = math.sqrt(area) / 2
|
side = math.sqrt(area) / 2
|
||||||
center = transform_points ( [(output_size/2,output_size/2)], mat, True)
|
center = transform_points ( [(output_size/2,output_size/2)], mat, True)
|
||||||
|
|
||||||
pts1 = np.float32([ center+[-side,-side], center+[side,-side], center+[-side,side] ])
|
pts1 = np.float32([ center+[-side,-side], center+[side,-side], center+[-side,side] ])
|
||||||
pts2 = np.float32([[0,0],[output_size-1,0],[0,output_size-1]])
|
pts2 = np.float32([[0,0],[output_size-1,0],[0,output_size-1]])
|
||||||
mat = cv2.getAffineTransform(pts1,pts2)
|
mat = cv2.getAffineTransform(pts1,pts2)
|
||||||
|
@ -209,7 +209,7 @@ def get_image_hull_mask (image_shape, image_landmarks, ie_polys=None):
|
||||||
|
|
||||||
for item in parts:
|
for item in parts:
|
||||||
merged = np.concatenate(item)
|
merged = np.concatenate(item)
|
||||||
cv2.fillConvexPoly(hull_mask, cv2.convexHull(merged), 255.) # pylint: disable=no-member
|
cv2.fillConvexPoly(hull_mask, cv2.convexHull(merged), 1)
|
||||||
|
|
||||||
if ie_polys is not None:
|
if ie_polys is not None:
|
||||||
ie_polys.overlay_mask(hull_mask)
|
ie_polys.overlay_mask(hull_mask)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue