Skip to content

Commit c073f19

Browse files
committed
Add init dir logs (copy opt yaml)
1 parent a51b1d9 commit c073f19

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

train.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import shutil
44
import yaml
55
import json
6+
import click
67
from pprint import pprint
78

89
import torch
@@ -139,6 +140,16 @@ def main():
139140
if args.resume:
140141
args.start_epoch, best_acc1, exp_logger = load_checkpoint(model.module, optimizer,
141142
os.path.join(options['logs']['dir_logs'], args.resume))
143+
else:
144+
# Or create logs directory
145+
if os.path.isdir(options['logs']['dir_logs']):
146+
if click.confirm('Logs directory already exists in {}. Erase?'
147+
.format(options['logs']['dir_logs'], default=False)):
148+
os.system('rm -r '+options['logs']['dir_logs'])
149+
else:
150+
return
151+
os.system('mkdir -p '+options['logs']['dir_logs'])
152+
os.system('cp {} {}'.format(args.path_opt, options['logs']['dir_logs']))
142153

143154
if exp_logger is None:
144155
# Set loggers

0 commit comments

Comments
 (0)