mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-07 21:42:08 -07:00
fix loss history
This commit is contained in:
parent
e6fa021c3d
commit
2473dabf37
4 changed files with 53 additions and 36 deletions
|
@ -153,7 +153,7 @@ Only H64 model reasonable to train on home CPU.
|
|||
|
||||
### Mac/linux/docker script support.
|
||||
|
||||
This repo supports only windows build of scripts. If you want to support mac/linux/docker - create such fork, it will be referenced here.
|
||||
This repo supports only windows build of scripts. If you want to support mac/linux/docker - create fork, it will be referenced here.
|
||||
|
||||
### Prebuilt windows app:
|
||||
|
||||
|
|
|
@ -196,29 +196,28 @@ def previewThread (input_queue, output_queue):
|
|||
lh_len = len(loss_history)
|
||||
|
||||
l_per_col = lh_len / w
|
||||
plist_max = [ [ max (0.0, 0.0, *[ loss_history[i_ab][p]
|
||||
for i_ab in range( int(col*l_per_col), int((col+1)*l_per_col) )
|
||||
]
|
||||
)
|
||||
for p in range(0,loss_count)
|
||||
]
|
||||
for col in range(0, w)
|
||||
]
|
||||
|
||||
|
||||
plist_min = [ [ min (plist_max[col][p],
|
||||
plist_max[col][p],
|
||||
plist_max = [ [ max (0.0, loss_history[int(col*l_per_col)][p],
|
||||
*[ loss_history[i_ab][p]
|
||||
for i_ab in range( int(col*l_per_col), int((col+1)*l_per_col) )
|
||||
]
|
||||
)
|
||||
for p in range(0,loss_count)
|
||||
for p in range(loss_count)
|
||||
]
|
||||
for col in range(0, w)
|
||||
for col in range(w)
|
||||
]
|
||||
|
||||
plist_min = [ [ min (plist_max[col][p], loss_history[int(col*l_per_col)][p],
|
||||
*[ loss_history[i_ab][p]
|
||||
for i_ab in range( int(col*l_per_col), int((col+1)*l_per_col) )
|
||||
]
|
||||
)
|
||||
for p in range(loss_count)
|
||||
]
|
||||
for col in range(w)
|
||||
]
|
||||
|
||||
plist_abs_max = np.mean(loss_history[ len(loss_history) // 5 : ]) * 2
|
||||
|
||||
if l_per_col >= 1.0:
|
||||
for col in range(0, w):
|
||||
for p in range(0,loss_count):
|
||||
point_color = [1.0]*c
|
||||
|
@ -241,10 +240,7 @@ def previewThread (input_queue, output_queue):
|
|||
last_line_t = int((lh_lines-1)*lh_line_height)
|
||||
last_line_b = int(lh_lines*lh_line_height)
|
||||
|
||||
if epoch != 0:
|
||||
lh_text = 'Loss history. Epoch: %d' % (epoch)
|
||||
else:
|
||||
lh_text = 'Loss history.'
|
||||
lh_text = 'Epoch: %d' % (epoch) if epoch != 0 else ''
|
||||
|
||||
lh_img[last_line_t:last_line_b, 0:w] += image_utils.get_text_image ( (w,last_line_b-last_line_t,c), lh_text, color=head_text_color )
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class ModelBase(object):
|
|||
self.loss_history = model_data['loss_history'] if 'loss_history' in model_data.keys() else []
|
||||
self.sample_for_preview = model_data['sample_for_preview'] if 'sample_for_preview' in model_data.keys() else None
|
||||
|
||||
ask_override = self.is_training_mode and self.epoch != 0 and input_in_time ("Press enter during 2 seconds to override some model settings.", 2)
|
||||
ask_override = self.is_training_mode and self.epoch != 0 and input_in_time ("Press enter in 2 seconds to override some model settings.", 2)
|
||||
|
||||
if self.epoch == 0:
|
||||
print ("\nModel first run. Enter model options as default for each run.")
|
||||
|
|
|
@ -40,6 +40,7 @@ class nnlib(object):
|
|||
DSSIMMaskLoss = None
|
||||
PixelShuffler = None
|
||||
SubpixelUpscaler = None
|
||||
AddUniformNoise = None
|
||||
|
||||
ResNet = None
|
||||
UNet = None
|
||||
|
@ -101,6 +102,7 @@ DSSIMLoss = nnlib.DSSIMLoss
|
|||
DSSIMMaskLoss = nnlib.DSSIMMaskLoss
|
||||
PixelShuffler = nnlib.PixelShuffler
|
||||
SubpixelUpscaler = nnlib.SubpixelUpscaler
|
||||
AddUniformNoise = nnlib.AddUniformNoise
|
||||
"""
|
||||
code_import_keras_contrib_string = \
|
||||
"""
|
||||
|
@ -541,6 +543,25 @@ NLayerDiscriminator = nnlib.NLayerDiscriminator
|
|||
nnlib.PixelShuffler = PixelShuffler
|
||||
nnlib.SubpixelUpscaler = PixelShuffler
|
||||
|
||||
class AddUniformNoise(keras.layers.Layer):
|
||||
def __init__(self, power=1.0, minval=-1.0, maxval=1.0, **kwargs):
|
||||
super(AddUniformNoise, self).__init__(**kwargs)
|
||||
self.power = power
|
||||
self.supports_masking = True
|
||||
self.minval = minval
|
||||
self.maxval = maxval
|
||||
|
||||
def call(self, inputs, training=None):
|
||||
def noised():
|
||||
return inputs + self.power*K.random_uniform(shape=K.shape(inputs), minval=self.minval, maxval=self.maxval)
|
||||
return K.in_train_phase(noised, inputs, training=training)
|
||||
|
||||
def get_config(self):
|
||||
config = {'power': self.power, 'minval': self.minval, 'maxval': self.maxval}
|
||||
base_config = super(AddUniformNoise, self).get_config()
|
||||
return dict(list(base_config.items()) + list(config.items()))
|
||||
nnlib.AddUniformNoise = AddUniformNoise
|
||||
|
||||
@staticmethod
|
||||
def import_keras_contrib(device_config = None):
|
||||
if nnlib.keras_contrib is not None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue