mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-08-21 22:13:20 -07:00
try casting
This commit is contained in:
parent
0225a29832
commit
ce5f479f9f
1 changed files with 3 additions and 4 deletions
|
@ -17,10 +17,9 @@ class MsSsim(nn.LayerBase):
|
|||
|
||||
def __call__(self, y_true, y_pred, max_val):
|
||||
# Transpose images from NCHW to NHWC
|
||||
y_true_t = tf.transpose(y_true, [0, 2, 3, 1])
|
||||
y_pred_t = tf.transpose(y_pred, [0, 2, 3, 1])
|
||||
with tf.device('/CPU:0'):
|
||||
loss = tf.image.ssim_multiscale(y_true_t, y_pred_t, max_val, power_factors=self.power_factors)
|
||||
y_true_t = tf.transpose(tf.cast(y_true), [0, 2, 3, 1])
|
||||
y_pred_t = tf.transpose(tf.cast(y_pred), [0, 2, 3, 1])
|
||||
loss = tf.image.ssim_multiscale(y_true_t, y_pred_t, max_val, power_factors=self.power_factors)
|
||||
return (1.0 - loss) / 2.0
|
||||
|
||||
nn.MsSsim = MsSsim
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue