mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-08-22 14:24:40 -07:00
caf mask update
This commit is contained in:
parent
70cf79f378
commit
8eeb7632a0
2 changed files with 6 additions and 18 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,3 +6,5 @@
|
|||
!requirements*
|
||||
!Dockerfile*
|
||||
!*.sh
|
||||
train.py
|
||||
convert.py
|
||||
|
|
|
@ -12,8 +12,6 @@ from utils.pickle_utils import AntiPickler
|
|||
|
||||
from .Converter import Converter
|
||||
|
||||
import math
|
||||
|
||||
|
||||
'''
|
||||
default_mode = {1:'overlay',
|
||||
|
@ -253,24 +251,16 @@ class ConverterMasked(Converter):
|
|||
if ero > 0:
|
||||
img_face_mask_aaa = cv2.erode(img_face_mask_aaa, cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(ero,ero)), iterations = 1 )
|
||||
elif ero < 0:
|
||||
inverted_old_mask = 1 - img_face_mask_aaa
|
||||
left_jaw_landmark = img_face_landmarks[0]
|
||||
right_jaw_landmark = img_face_landmarks[16]
|
||||
|
||||
inverted_old_mask[0: int(left_jaw_landmark[1]), 0: int(right_jaw_landmark[0])] = 0
|
||||
inverted_old_mask[0: int(right_jaw_landmark[1]), int(left_jaw_landmark[0]): -1] = 0
|
||||
img_face_mask_aaa = cv2.dilate(img_face_mask_aaa, cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(-ero,-ero)), iterations = 1 )
|
||||
|
||||
# img_face_mask_aaa = img_face_mask_aaa - inverted_old_mask
|
||||
# img_face_mask_aaa = np.clip(img_face_mask_aaa, 0, 1)
|
||||
|
||||
img_mask_blurry_aaa = img_face_mask_aaa
|
||||
|
||||
if self.clip_hborder_mask_per > 0: #clip hborder before blur
|
||||
prd_hborder_rect_mask_a = np.ones ( prd_face_mask_a.shape, dtype=np.float32)
|
||||
prd_border_size = int ( prd_hborder_rect_mask_a.shape[1] * self.clip_hborder_mask_per )
|
||||
prd_hborder_rect_mask_a[:,0:prd_border_size,:] = 0
|
||||
prd_hborder_rect_mask_a[:,-prd_border_size:,:] = 0
|
||||
prd_hborder_rect_mask_a[:,-prd_border_size:,:] = 0
|
||||
prd_hborder_rect_mask_a[-prd_border_size:,:,:] = 0
|
||||
prd_hborder_rect_mask_a = np.expand_dims(cv2.blur(prd_hborder_rect_mask_a, (prd_border_size, prd_border_size) ),-1)
|
||||
|
||||
img_prd_hborder_rect_mask_a = cv2.warpAffine( prd_hborder_rect_mask_a, face_output_mat, img_size, np.zeros(img_bgr.shape, dtype=np.float32), cv2.WARP_INVERSE_MAP | cv2.INTER_LANCZOS4 )
|
||||
|
@ -289,10 +279,6 @@ class ConverterMasked(Converter):
|
|||
img_mask_blurry_aaa = cv2.blur(img_mask_blurry_aaa, (blur, blur) )
|
||||
|
||||
img_mask_blurry_aaa = np.clip( img_mask_blurry_aaa, 0, 1.0 )
|
||||
|
||||
if ero < 0:
|
||||
img_mask_blurry_aaa = img_mask_blurry_aaa - inverted_old_mask
|
||||
img_mask_blurry_aaa = np.clip(img_mask_blurry_aaa, 0, 1)
|
||||
face_mask_blurry_aaa = cv2.warpAffine( img_mask_blurry_aaa, face_mat, (output_size, output_size) )
|
||||
|
||||
if debug:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue