diff --git a/models/Model_AMP/Model.py b/models/Model_AMP/Model.py index 7190704..575b318 100644 --- a/models/Model_AMP/Model.py +++ b/models/Model_AMP/Model.py @@ -390,18 +390,17 @@ class AMPModel(ModelBase): gpu_target_dstm_anti_blur = 1.0-gpu_target_dstm_blur if blur_out_mask: - #gpu_target_src = gpu_target_src*gpu_target_srcm_blur + nn.gaussian_blur(gpu_target_src, resolution // 32)*gpu_target_srcm_anti_blur - #gpu_target_dst = gpu_target_dst*gpu_target_dstm_blur + nn.gaussian_blur(gpu_target_dst, resolution // 32)*gpu_target_dstm_anti_blur - bg_blur_div = 128 - - gpu_target_src = gpu_target_src*gpu_target_srcm + \ - tf.math.divide_no_nan(nn.gaussian_blur(gpu_target_src*gpu_target_srcm_anti, resolution / bg_blur_div), - (1-nn.gaussian_blur(gpu_target_srcm, resolution / bg_blur_div) ) ) * gpu_target_srcm_anti - - gpu_target_dst = gpu_target_dst*gpu_target_dstm + \ - tf.math.divide_no_nan(nn.gaussian_blur(gpu_target_dst*gpu_target_dstm_anti, resolution / bg_blur_div), - (1-nn.gaussian_blur(gpu_target_dstm, resolution / bg_blur_div)) ) * gpu_target_dstm_anti - + sigma = resolution / 128 + + x = nn.gaussian_blur(gpu_target_src*gpu_target_srcm_anti, sigma) + y = 1-nn.gaussian_blur(gpu_target_srcm, sigma) + y = tf.where(tf.equal(y, 0), tf.ones_like(y), y) + gpu_target_src = gpu_target_src*gpu_target_srcm + (x/y)*gpu_target_srcm_anti + + x = nn.gaussian_blur(gpu_target_dst*gpu_target_dstm_anti, sigma) + y = 1-nn.gaussian_blur(gpu_target_dstm, sigma) + y = tf.where(tf.equal(y, 0), tf.ones_like(y), y) + gpu_target_dst = gpu_target_dst*gpu_target_dstm + (x/y)*gpu_target_dstm_anti gpu_target_src_masked = gpu_target_src*gpu_target_srcm_blur gpu_target_dst_masked = gpu_target_dst*gpu_target_dstm_blur @@ -628,7 +627,7 @@ class AMPModel(ModelBase): name='AMP', input_names=['in_face:0','morph_value:0'], output_names=['out_face_mask:0','out_celeb_face:0','out_celeb_face_mask:0'], - opset=13, + opset=9, output_path=output_path) #override diff --git a/models/Model_SAEHD/Model.py b/models/Model_SAEHD/Model.py index 05325fa..3cc01a1 100644 --- a/models/Model_SAEHD/Model.py +++ b/models/Model_SAEHD/Model.py @@ -375,18 +375,19 @@ Examples: df, liae, df-d, df-ud, liae-ud, ... gpu_target_dstm_anti = 1-gpu_target_dstm if blur_out_mask: - #gpu_target_src = gpu_target_src*gpu_target_srcm_blur + nn.gaussian_blur(gpu_target_src, resolution // 32)*gpu_target_srcm_anti_blur - #gpu_target_dst = gpu_target_dst*gpu_target_dstm_blur + nn.gaussian_blur(gpu_target_dst, resolution // 32)*gpu_target_dstm_anti_blur - bg_blur_div = 128 - - gpu_target_src = gpu_target_src*gpu_target_srcm + \ - tf.math.divide_no_nan(nn.gaussian_blur(gpu_target_src*gpu_target_srcm_anti, resolution / bg_blur_div), - (1-nn.gaussian_blur(gpu_target_srcm, resolution / bg_blur_div) ) ) * gpu_target_srcm_anti - - gpu_target_dst = gpu_target_dst*gpu_target_dstm + \ - tf.math.divide_no_nan(nn.gaussian_blur(gpu_target_dst*gpu_target_dstm_anti, resolution / bg_blur_div), - (1-nn.gaussian_blur(gpu_target_dstm, resolution / bg_blur_div)) ) * gpu_target_dstm_anti + sigma = resolution / 128 + + x = nn.gaussian_blur(gpu_target_src*gpu_target_srcm_anti, sigma) + y = 1-nn.gaussian_blur(gpu_target_srcm, sigma) + y = tf.where(tf.equal(y, 0), tf.ones_like(y), y) + gpu_target_src = gpu_target_src*gpu_target_srcm + (x/y)*gpu_target_srcm_anti + + x = nn.gaussian_blur(gpu_target_dst*gpu_target_dstm_anti, sigma) + y = 1-nn.gaussian_blur(gpu_target_dstm, sigma) + y = tf.where(tf.equal(y, 0), tf.ones_like(y), y) + gpu_target_dst = gpu_target_dst*gpu_target_dstm + (x/y)*gpu_target_dstm_anti + # process model tensors if 'df' in archi_type: gpu_src_code = self.inter(self.encoder(gpu_warped_src)) @@ -742,7 +743,7 @@ Examples: df, liae, df-d, df-ud, liae-ud, ... name='SAEHD', input_names=['in_face:0'], output_names=['out_face_mask:0','out_celeb_face:0','out_celeb_face_mask:0'], - opset=13, + opset=9, output_path=output_path) #override