Merge pull request #64 from faceshiftlabs/feat/mask-2nd-column

Add mask to 2nd column of previews
This commit is contained in:
Jeremy Hummel 2019-09-12 19:44:43 -07:00 committed by GitHub
commit 247215d3a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -440,8 +440,9 @@ class SAEModel(ModelBase):
if self.options['learn_mask']: if self.options['learn_mask']:
self.AE_view = K.function([warped_src, warped_dst], self.AE_view = K.function([warped_src, warped_dst],
[pred_src_src[-1], pred_dst_dst[-1], pred_dst_dstm[-1], pred_src_dst[-1], [pred_src_src[-1], pred_src_srcm[-1],
pred_src_dstm[-1]]) pred_dst_dst[-1], pred_dst_dstm[-1],
pred_src_dst[-1], pred_src_dstm[-1]])
else: else:
self.AE_view = K.function([warped_src, warped_dst], self.AE_view = K.function([warped_src, warped_dst],
[pred_src_src[-1], pred_dst_dst[-1], pred_src_dst[-1]]) [pred_src_src[-1], pred_dst_dst[-1], pred_src_dst[-1]])
@ -579,9 +580,9 @@ class SAEModel(ModelBase):
test_D_m = sample[1][1+self.ms_count][0:4] test_D_m = sample[1][1+self.ms_count][0:4]
if self.options['learn_mask']: if self.options['learn_mask']:
S, D, SS, DD, DDM, SD, SDM = [np.clip(x, 0.0, 1.0) for x in S, D, SS, SSM, DD, DDM, SD, SDM = [np.clip(x, 0.0, 1.0) for x in
([test_S, test_D] + self.AE_view([test_S, test_D]))] ([test_S, test_D] + self.AE_view([test_S, test_D]))]
DDM, SDM, = [ np.repeat (x, (3,), -1) for x in [DDM, SDM] ] SSM, DDM, SDM, = [ np.repeat (x, (3,), -1) for x in [SSM, DDM, SDM] ]
else: else:
S, D, SS, DD, SD, = [ np.clip(x, 0.0, 1.0) for x in ([test_S,test_D] + self.AE_view ([test_S, test_D]) ) ] S, D, SS, DD, SD, = [ np.clip(x, 0.0, 1.0) for x in ([test_S,test_D] + self.AE_view ([test_S, test_D]) ) ]
@ -596,7 +597,7 @@ class SAEModel(ModelBase):
if self.options['learn_mask']: if self.options['learn_mask']:
st_m = [] st_m = []
for i in range(0, len(test_S)): for i in range(0, len(test_S)):
ar = S[i]*test_S_m[i], SS[i], D[i]*test_D_m[i], DD[i]*DDM[i], SD[i]*(DDM[i]*SDM[i]) ar = S[i]*test_S_m[i], SS[i]*SSM[i], D[i]*test_D_m[i], DD[i]*DDM[i], SD[i]*(DDM[i]*SDM[i])
st_m.append ( np.concatenate ( ar, axis=1) ) st_m.append ( np.concatenate ( ar, axis=1) )
result += [ ('SAE masked', np.concatenate (st_m, axis=0 )), ] result += [ ('SAE masked', np.concatenate (st_m, axis=0 )), ]