mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-08-22 06:23:20 -07:00
soft placement
This commit is contained in:
parent
6a68dd5e59
commit
2e4fdf20ca
2 changed files with 2 additions and 6 deletions
|
@ -1,6 +1,5 @@
|
||||||
from core.leras import nn
|
from core.leras import nn
|
||||||
tf = nn.tf
|
tf = nn.tf
|
||||||
tf2 = nn.tf2
|
|
||||||
|
|
||||||
class MsSsim(nn.LayerBase):
|
class MsSsim(nn.LayerBase):
|
||||||
default_power_factors = (0.0448, 0.2856, 0.3001, 0.2363, 0.1333)
|
default_power_factors = (0.0448, 0.2856, 0.3001, 0.2363, 0.1333)
|
||||||
|
@ -21,7 +20,7 @@ class MsSsim(nn.LayerBase):
|
||||||
y_true_t = tf.transpose(tf.cast(y_true, tf.float32), [0, 2, 3, 1])
|
y_true_t = tf.transpose(tf.cast(y_true, tf.float32), [0, 2, 3, 1])
|
||||||
y_pred_t = tf.transpose(tf.cast(y_pred, tf.float32), [0, 2, 3, 1])
|
y_pred_t = tf.transpose(tf.cast(y_pred, tf.float32), [0, 2, 3, 1])
|
||||||
|
|
||||||
loss = tf2.image.ssim_multiscale(y_true_t, y_pred_t, max_val, power_factors=self.power_factors)
|
loss = tf.image.ssim_multiscale(y_true_t, y_pred_t, max_val, power_factors=self.power_factors)
|
||||||
return (1.0 - loss) / 2.0
|
return (1.0 - loss) / 2.0
|
||||||
|
|
||||||
nn.MsSsim = MsSsim
|
nn.MsSsim = MsSsim
|
||||||
|
|
|
@ -31,7 +31,6 @@ class nn():
|
||||||
current_DeviceConfig = None
|
current_DeviceConfig = None
|
||||||
|
|
||||||
tf = None
|
tf = None
|
||||||
tf2 = None
|
|
||||||
tf_sess = None
|
tf_sess = None
|
||||||
tf_sess_config = None
|
tf_sess_config = None
|
||||||
tf_default_device = None
|
tf_default_device = None
|
||||||
|
@ -87,8 +86,6 @@ class nn():
|
||||||
|
|
||||||
if tf_version[0] == '2':
|
if tf_version[0] == '2':
|
||||||
tf = tensorflow.compat.v1
|
tf = tensorflow.compat.v1
|
||||||
tf2 = tensorflow
|
|
||||||
nn.tf2 = tf2
|
|
||||||
else:
|
else:
|
||||||
tf = tensorflow
|
tf = tensorflow
|
||||||
|
|
||||||
|
@ -115,7 +112,7 @@ class nn():
|
||||||
config = tf.ConfigProto(device_count={'GPU': 0})
|
config = tf.ConfigProto(device_count={'GPU': 0})
|
||||||
else:
|
else:
|
||||||
nn.tf_default_device = "/GPU:0"
|
nn.tf_default_device = "/GPU:0"
|
||||||
config = tf.ConfigProto()
|
config = tf.ConfigProto(allow_soft_placement=True)
|
||||||
config.gpu_options.visible_device_list = ','.join([str(device.index) for device in device_config.devices])
|
config.gpu_options.visible_device_list = ','.join([str(device.index) for device in device_config.devices])
|
||||||
|
|
||||||
config.gpu_options.force_gpu_compatible = True
|
config.gpu_options.force_gpu_compatible = True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue