Trainer: added option for all models

Enable autobackup? (y/n ?:help skip:%s) :
Autobackup model files with preview every hour for last 15 hours. Latest backup located in model/<>_autobackups/01

SAE: added option only for CUDA builds:
Enable gradient clipping? (y/n, ?:help skip:%s) :
Gradient clipping reduces chance of model collapse, sacrificing speed of training.
This commit is contained in:
iperov 2019-06-20 10:42:55 +04:00
parent ea1d59f620
commit 8484060e01
14 changed files with 210 additions and 80 deletions

View file

@ -27,7 +27,24 @@ def get_image_unique_filestem_paths(dir_path, verbose_print_func=None):
result_dup.add(f_stem)
return result
def get_file_paths(dir_path):
dir_path = Path (dir_path)
result = []
if dir_path.exists():
return [ x.path for x in list(scandir(str(dir_path))) if x.is_file() ]
return result
def get_all_dir_names (dir_path):
dir_path = Path (dir_path)
result = []
if dir_path.exists():
return [ x.name for x in list(scandir(str(dir_path))) if x.is_dir() ]
return result
def get_all_dir_names_startswith (dir_path, startswith):
dir_path = Path (dir_path)
startswith = startswith.lower()
@ -52,3 +69,15 @@ def get_first_file_by_stem (dir_path, stem, exts=None):
return xp
return None
def move_all_files (src_dir_path, dst_dir_path):
paths = get_file_paths(src_dir_path)
for p in paths:
p = Path(p)
p.rename ( Path(dst_dir_path) / p.name )
def delete_all_files (dir_path):
paths = get_file_paths(dir_path)
for p in paths:
p = Path(p)
p.unlink()