glenn-jocher commited on
Commit
603ea0b
·
1 Parent(s): 72d5b58

update log_dir to runs/exp #107

Browse files
Files changed (2) hide show
  1. train.py +1 -1
  2. utils/utils.py +10 -0
train.py CHANGED
@@ -396,7 +396,7 @@ if __name__ == '__main__':
396
  # Train
397
  if not opt.evolve:
398
  print('Start Tensorboard with "tensorboard --logdir=runs", view at http://localhost:6006/')
399
- tb_writer = SummaryWriter(comment=opt.name)
400
  if opt.hyp: # update hyps
401
  with open(opt.hyp) as f:
402
  hyp.update(yaml.load(f, Loader=yaml.FullLoader))
 
396
  # Train
397
  if not opt.evolve:
398
  print('Start Tensorboard with "tensorboard --logdir=runs", view at http://localhost:6006/')
399
+ tb_writer = SummaryWriter(log_dir=increment_dir('runs/exp', opt.name))
400
  if opt.hyp: # update hyps
401
  with open(opt.hyp) as f:
402
  hyp.update(yaml.load(f, Loader=yaml.FullLoader))
utils/utils.py CHANGED
@@ -904,6 +904,16 @@ def output_to_target(output, width, height):
904
  return np.array(targets)
905
 
906
 
 
 
 
 
 
 
 
 
 
 
907
  # Plotting functions ---------------------------------------------------------------------------------------------------
908
  def butter_lowpass_filtfilt(data, cutoff=1500, fs=50000, order=5):
909
  # https://stackoverflow.com/questions/28536191/how-to-filter-smooth-with-scipy-numpy
 
904
  return np.array(targets)
905
 
906
 
907
+ def increment_dir(dir, comment=''):
908
+ # Increments a directory runs/exp1 --> runs/exp2_comment
909
+ n = 0 # number
910
+ d = sorted(glob.glob(dir + '*')) # directories
911
+ if len(d):
912
+ d = d[-1].replace(dir, '')
913
+ n = int(d[:d.find('_')]) + 1 # increment
914
+ return dir + str(n) + ('_' + comment if comment else '')
915
+
916
+
917
  # Plotting functions ---------------------------------------------------------------------------------------------------
918
  def butter_lowpass_filtfilt(data, cutoff=1500, fs=50000, order=5):
919
  # https://stackoverflow.com/questions/28536191/how-to-filter-smooth-with-scipy-numpy