From 9e50b59f6fd62156a010c8c5f2aa90912df05f5a Mon Sep 17 00:00:00 2001 From: iperov Date: Sat, 2 Oct 2021 00:13:29 +0400 Subject: [PATCH] fix --- apps/DeepFaceLive/backend/FaceMerger.py | 6 +++--- xlib/avecl/_internal/op/binary_morph.py | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/DeepFaceLive/backend/FaceMerger.py b/apps/DeepFaceLive/backend/FaceMerger.py index 149909e..998ff2f 100644 --- a/apps/DeepFaceLive/backend/FaceMerger.py +++ b/apps/DeepFaceLive/backend/FaceMerger.py @@ -196,10 +196,10 @@ class FaceMergerWorker(BackendWorker): if state.face_mask_type == FaceMaskType.SRC: face_mask_t = lib_cl.Tensor.from_value(face_align_mask_img) - face_mask_t = face_mask_t.transpose( (2,0,1), op_text='O = (I <= 128 ? 0 : 1);', dtype=np.uint8) + face_mask_t = face_mask_t.transpose( (2,0,1), op_text='O = (I < 128 ? 0 : 1);', dtype=np.uint8) elif state.face_mask_type == FaceMaskType.CELEB: face_mask_t = lib_cl.Tensor.from_value(face_swap_mask_img) - face_mask_t = face_mask_t.transpose( (2,0,1), op_text='O = (I <= 128 ? 0 : 1);', dtype=np.uint8) + face_mask_t = face_mask_t.transpose( (2,0,1), op_text='O = (I < 128 ? 0 : 1);', dtype=np.uint8) elif state.face_mask_type == FaceMaskType.SRC_M_CELEB: face_mask_t = lib_cl.any_wise('float X = (((float)I0) / 255.0) * (((float)I1) / 255.0); O = (X <= 0.5 ? 0 : 1);', @@ -214,7 +214,7 @@ class FaceMergerWorker(BackendWorker): frame_face_mask_t = lib_cl.remap_np_affine(face_mask_t, aligned_to_source_uni_mat, output_size=(frame_height, frame_width) ) frame_face_swap_img_t = lib_cl.remap_np_affine(face_swap_img_t, aligned_to_source_uni_mat, output_size=(frame_height, frame_width) ) - + frame_image_t = lib_cl.Tensor.from_value(frame_image).transpose( (2,0,1) ) opacity = state.face_opacity diff --git a/xlib/avecl/_internal/op/binary_morph.py b/xlib/avecl/_internal/op/binary_morph.py index f0dc5b2..4541a56 100644 --- a/xlib/avecl/_internal/op/binary_morph.py +++ b/xlib/avecl/_internal/op/binary_morph.py @@ -3,7 +3,7 @@ from .binary_dilate_circle import binary_dilate_circle from .binary_erode_circle import binary_erode_circle from .gaussian_blur import gaussian_blur from .pad import pad - +from .cast import cast def binary_morph(input_t : Tensor, erode_dilate : int, blur : float, fade_to_border : bool = False, dtype=None) -> Tensor: """ @@ -39,5 +39,7 @@ def binary_morph(input_t : Tensor, erode_dilate : int, blur : float, fade_to_bor if blur > 0: x = gaussian_blur(x, blur * 0.250, dtype=dtype) - + else: + x = cast(x, dtype=dtype) + return x[...,H:-H,W:-W]