mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-08 05:51:40 -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.
|
### 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:
|
### Prebuilt windows app:
|
||||||
|
|
||||||
|
|
|
@ -196,42 +196,41 @@ def previewThread (input_queue, output_queue):
|
||||||
lh_len = len(loss_history)
|
lh_len = len(loss_history)
|
||||||
|
|
||||||
l_per_col = lh_len / w
|
l_per_col = lh_len / w
|
||||||
plist_max = [ [ max (0.0, 0.0, *[ loss_history[i_ab][p]
|
plist_max = [ [ max (0.0, loss_history[int(col*l_per_col)][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],
|
|
||||||
*[ loss_history[i_ab][p]
|
*[ loss_history[i_ab][p]
|
||||||
for i_ab in range( int(col*l_per_col), int((col+1)*l_per_col) )
|
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
|
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 col in range(0, w):
|
for p in range(0,loss_count):
|
||||||
for p in range(0,loss_count):
|
point_color = [1.0]*c
|
||||||
point_color = [1.0]*c
|
point_color[0:3] = colorsys.hsv_to_rgb ( p * (1.0/loss_count), 1.0, 1.0 )
|
||||||
point_color[0:3] = colorsys.hsv_to_rgb ( p * (1.0/loss_count), 1.0, 1.0 )
|
|
||||||
|
|
||||||
ph_max = int ( (plist_max[col][p] / plist_abs_max) * (lh_height-1) )
|
ph_max = int ( (plist_max[col][p] / plist_abs_max) * (lh_height-1) )
|
||||||
ph_max = np.clip( ph_max, 0, lh_height-1 )
|
ph_max = np.clip( ph_max, 0, lh_height-1 )
|
||||||
|
|
||||||
ph_min = int ( (plist_min[col][p] / plist_abs_max) * (lh_height-1) )
|
ph_min = int ( (plist_min[col][p] / plist_abs_max) * (lh_height-1) )
|
||||||
ph_min = np.clip( ph_min, 0, lh_height-1 )
|
ph_min = np.clip( ph_min, 0, lh_height-1 )
|
||||||
|
|
||||||
for ph in range(ph_min, ph_max+1):
|
for ph in range(ph_min, ph_max+1):
|
||||||
lh_img[ (lh_height-ph-1), col ] = point_color
|
lh_img[ (lh_height-ph-1), col ] = point_color
|
||||||
|
|
||||||
lh_lines = 5
|
lh_lines = 5
|
||||||
lh_line_height = (lh_height-1)/lh_lines
|
lh_line_height = (lh_height-1)/lh_lines
|
||||||
|
@ -241,10 +240,7 @@ def previewThread (input_queue, output_queue):
|
||||||
last_line_t = int((lh_lines-1)*lh_line_height)
|
last_line_t = int((lh_lines-1)*lh_line_height)
|
||||||
last_line_b = int(lh_lines*lh_line_height)
|
last_line_b = int(lh_lines*lh_line_height)
|
||||||
|
|
||||||
if epoch != 0:
|
lh_text = 'Epoch: %d' % (epoch) if epoch != 0 else ''
|
||||||
lh_text = 'Loss history. Epoch: %d' % (epoch)
|
|
||||||
else:
|
|
||||||
lh_text = 'Loss history.'
|
|
||||||
|
|
||||||
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 )
|
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.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
|
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:
|
if self.epoch == 0:
|
||||||
print ("\nModel first run. Enter model options as default for each run.")
|
print ("\nModel first run. Enter model options as default for each run.")
|
||||||
|
|
|
@ -40,6 +40,7 @@ class nnlib(object):
|
||||||
DSSIMMaskLoss = None
|
DSSIMMaskLoss = None
|
||||||
PixelShuffler = None
|
PixelShuffler = None
|
||||||
SubpixelUpscaler = None
|
SubpixelUpscaler = None
|
||||||
|
AddUniformNoise = None
|
||||||
|
|
||||||
ResNet = None
|
ResNet = None
|
||||||
UNet = None
|
UNet = None
|
||||||
|
@ -101,6 +102,7 @@ DSSIMLoss = nnlib.DSSIMLoss
|
||||||
DSSIMMaskLoss = nnlib.DSSIMMaskLoss
|
DSSIMMaskLoss = nnlib.DSSIMMaskLoss
|
||||||
PixelShuffler = nnlib.PixelShuffler
|
PixelShuffler = nnlib.PixelShuffler
|
||||||
SubpixelUpscaler = nnlib.SubpixelUpscaler
|
SubpixelUpscaler = nnlib.SubpixelUpscaler
|
||||||
|
AddUniformNoise = nnlib.AddUniformNoise
|
||||||
"""
|
"""
|
||||||
code_import_keras_contrib_string = \
|
code_import_keras_contrib_string = \
|
||||||
"""
|
"""
|
||||||
|
@ -541,6 +543,25 @@ NLayerDiscriminator = nnlib.NLayerDiscriminator
|
||||||
nnlib.PixelShuffler = PixelShuffler
|
nnlib.PixelShuffler = PixelShuffler
|
||||||
nnlib.SubpixelUpscaler = 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
|
@staticmethod
|
||||||
def import_keras_contrib(device_config = None):
|
def import_keras_contrib(device_config = None):
|
||||||
if nnlib.keras_contrib is not None:
|
if nnlib.keras_contrib is not None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue