mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-06 04:52:13 -07:00
fix
This commit is contained in:
parent
5efb430f2a
commit
f95682f616
2 changed files with 23 additions and 15 deletions
|
@ -345,11 +345,9 @@ def ConvertMaskedFace (predictor_func, predictor_input_shape, cfg, frame_info, i
|
|||
alpha = cfg.color_degrade_power / 100.0
|
||||
out_img = (out_img*(1.0-alpha) + out_img_reduced*alpha)
|
||||
|
||||
if cfg.export_mask_alpha:
|
||||
out_img = np.concatenate ( [out_img, img_face_mask_aaa[:,:,0:1]], -1 )
|
||||
out_merging_mask = img_face_mask_aaa
|
||||
|
||||
return out_img, out_merging_mask
|
||||
return out_img, out_merging_mask[...,0:1]
|
||||
|
||||
|
||||
def ConvertMasked (predictor_func, predictor_input_shape, cfg, frame_info):
|
||||
|
@ -364,18 +362,18 @@ def ConvertMasked (predictor_func, predictor_input_shape, cfg, frame_info):
|
|||
|
||||
#Combining multiple face outputs
|
||||
final_img = None
|
||||
final_mask = None
|
||||
for img, merging_mask in outs:
|
||||
h,w,c = img.shape
|
||||
|
||||
if final_img is None:
|
||||
final_img = img
|
||||
final_mask = merging_mask
|
||||
else:
|
||||
merging_mask = merging_mask[...,0:1]
|
||||
if c == 3:
|
||||
final_img = final_img*(1-merging_mask) + img*merging_mask
|
||||
elif c == 4:
|
||||
final_img_bgr = final_img[...,0:3]*(1-merging_mask) + img[...,0:3]*merging_mask
|
||||
final_img_mask = np.clip ( final_img[...,3:4] + img[...,3:4], 0, 1 )
|
||||
final_img = np.concatenate ( [final_img_bgr, final_img_mask], -1 )
|
||||
final_mask = np.clip (final_mask + merging_mask, 0, 1 )
|
||||
|
||||
if cfg.export_mask_alpha:
|
||||
final_img = np.concatenate ( [final_img, final_mask], -1)
|
||||
|
||||
return (final_img*255).astype(np.uint8)
|
|
@ -170,6 +170,16 @@ class ConvertSubprocessor(Subprocessor):
|
|||
if len(landmarks_list) == 0:
|
||||
self.log_info ( 'no faces found for %s, copying without faces' % (filename_path.name) )
|
||||
|
||||
if cfg.export_mask_alpha:
|
||||
img_bgr = cv2_imread(filename)
|
||||
h,w,c = img_bgr.shape
|
||||
if c == 1:
|
||||
img_bgr = np.repeat(img_bgr, 3, -1)
|
||||
if c == 3:
|
||||
img_bgr = np.concatenate ([img_bgr, np.zeros((h,w,1), dtype=img_bgr.dtype) ], axis=-1)
|
||||
|
||||
cv2_imwrite (output_filename, img_bgr)
|
||||
else:
|
||||
if filename_path.suffix == '.png':
|
||||
shutil.copy (filename, output_filename )
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue