mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-06 21:12:07 -07:00
Trainer: fixed "Choose image for the preview history". Now you can switch between subpreviews using 'space' key.
Fixed "Write preview history". Now it writes all subpreviews in separated folders https://i.imgur.com/IszifCJ.jpg also the last preview saved as _last.jpg before the first file https://i.imgur.com/Ls1AOK4.jpg thus you can easily check the changes with the first file in photo viewer
This commit is contained in:
parent
5c315cab68
commit
82f405ed49
1 changed files with 35 additions and 23 deletions
|
@ -220,15 +220,17 @@ class ModelBase(object):
|
|||
def update_sample_for_preview(self, choose_preview_history=False, force_new=False):
|
||||
if self.sample_for_preview is None or choose_preview_history or force_new:
|
||||
if choose_preview_history and io.is_support_windows():
|
||||
io.log_info ("Choose image for the preview history. [p] - next. [enter] - confirm.")
|
||||
wnd_name = "[p] - next. [enter] - confirm."
|
||||
wnd_name = "[p] - next. [space] - switch preview type. [enter] - confirm."
|
||||
io.log_info (f"Choose image for the preview history. {wnd_name}")
|
||||
io.named_window(wnd_name)
|
||||
io.capture_keys(wnd_name)
|
||||
choosed = False
|
||||
preview_id_counter = 0
|
||||
while not choosed:
|
||||
self.sample_for_preview = self.generate_next_samples()
|
||||
preview = self.get_static_preview()
|
||||
io.show_image( wnd_name, (preview*255).astype(np.uint8) )
|
||||
previews = self.get_static_previews()
|
||||
|
||||
io.show_image( wnd_name, ( previews[preview_id_counter % len(previews) ][1] *255).astype(np.uint8) )
|
||||
|
||||
while True:
|
||||
key_events = io.get_key_events(wnd_name)
|
||||
|
@ -236,6 +238,9 @@ class ModelBase(object):
|
|||
if key == ord('\n') or key == ord('\r'):
|
||||
choosed = True
|
||||
break
|
||||
elif key == ord(' '):
|
||||
preview_id_counter += 1
|
||||
break
|
||||
elif key == ord('p'):
|
||||
break
|
||||
|
||||
|
@ -249,7 +254,7 @@ class ModelBase(object):
|
|||
self.sample_for_preview = self.generate_next_samples()
|
||||
|
||||
try:
|
||||
self.get_static_preview()
|
||||
self.get_static_previews()
|
||||
except:
|
||||
self.sample_for_preview = self.generate_next_samples()
|
||||
|
||||
|
@ -354,8 +359,8 @@ class ModelBase(object):
|
|||
def get_previews(self):
|
||||
return self.onGetPreview ( self.last_sample )
|
||||
|
||||
def get_static_preview(self):
|
||||
return self.onGetPreview (self.sample_for_preview)[0][1] #first preview, and bgr
|
||||
def get_static_previews(self):
|
||||
return self.onGetPreview (self.sample_for_preview)
|
||||
|
||||
def save(self):
|
||||
Path( self.get_summary_path() ).write_text( self.get_summary_text() )
|
||||
|
@ -455,7 +460,14 @@ class ModelBase(object):
|
|||
plist += [ (bgr, self.get_strpath_storage_for_file('preview_%s.jpg' % (name) ) ) ]
|
||||
|
||||
if self.write_preview_history:
|
||||
plist += [ (self.get_static_preview(), str (self.preview_history_path / ('%.6d.jpg' % (self.iter))) ) ]
|
||||
previews = self.get_static_previews()
|
||||
for i in range(len(previews)):
|
||||
name, bgr = previews[i]
|
||||
path = self.preview_history_path / name
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
plist += [ ( bgr, str ( path / ( f'{self.iter:07d}.jpg') ) ) ]
|
||||
if not io.is_colab():
|
||||
plist += [ ( bgr, str ( path / ( '_last.jpg' ) )) ]
|
||||
|
||||
for preview, filepath in plist:
|
||||
preview_lh = ModelBase.get_loss_history_preview(self.loss_history, self.iter, preview.shape[1], preview.shape[2])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue