add util function to get most recent last.pt file

added logic in train.py __main__ to handle resuming from a run
This commit is contained in:
Alex Stoken committed 2020-06-16 15:50:27 -05:00
1 parent 490f1e7b9c
commit 25e51bcec7
2 files changed
+16 -3

No files matched your search

+6
View File
@@ -36,6 +36,12 @@ def init_seeds(seed=0):
np.random.seed(seed)
torch_utils.init_seeds(seed=seed)
def get_latest_run(search_dir = './runs/'):
# get path to most recent 'last.pt' in run dirs
# assumes most recently saved 'last.pt' is the desired weights to --resume from
last_list = glob.glob('runs/*/last.pt')
latest = max(last_list, key = os.path.getctime)
return latest
def check_git_status():
# Suggest 'git pull' if repo is out of date