astoken commited on
Commit
e572bb0
·
1 Parent(s): c8152c8

Add plot_results save location to log_dir

Browse files
Files changed (2) hide show
  1. train.py +1 -1
  2. utils/utils.py +2 -2
train.py CHANGED
@@ -356,7 +356,7 @@ def train(hyp):
356
  os.system('gsutil cp %s gs://%s/weights' % (f2, opt.bucket)) if opt.bucket and ispt else None # upload
357
 
358
  if not opt.evolve:
359
- plot_results() # save as results.png
360
  print('%g epochs completed in %.3f hours.\n' % (epoch - start_epoch + 1, (time.time() - t0) / 3600))
361
  dist.destroy_process_group() if torch.cuda.device_count() > 1 else None
362
  torch.cuda.empty_cache()
 
356
  os.system('gsutil cp %s gs://%s/weights' % (f2, opt.bucket)) if opt.bucket and ispt else None # upload
357
 
358
  if not opt.evolve:
359
+ plot_results(save_dir = log_dir) # save as results.png
360
  print('%g epochs completed in %.3f hours.\n' % (epoch - start_epoch + 1, (time.time() - t0) / 3600))
361
  dist.destroy_process_group() if torch.cuda.device_count() > 1 else None
362
  torch.cuda.empty_cache()
utils/utils.py CHANGED
@@ -1154,7 +1154,7 @@ def plot_results_overlay(start=0, stop=0): # from utils.utils import *; plot_re
1154
  fig.savefig(f.replace('.txt', '.png'), dpi=200)
1155
 
1156
 
1157
- def plot_results(start=0, stop=0, bucket='', id=(), labels=()): # from utils.utils import *; plot_results()
1158
  # Plot training 'results*.txt' as seen in https://github.com/ultralytics/yolov5#reproduce-our-training
1159
  fig, ax = plt.subplots(2, 5, figsize=(12, 6))
1160
  ax = ax.ravel()
@@ -1164,7 +1164,7 @@ def plot_results(start=0, stop=0, bucket='', id=(), labels=()): # from utils.ut
1164
  os.system('rm -rf storage.googleapis.com')
1165
  files = ['https://storage.googleapis.com/%s/results%g.txt' % (bucket, x) for x in id]
1166
  else:
1167
- files = glob.glob('results*.txt') + glob.glob('../../Downloads/results*.txt')
1168
  for fi, f in enumerate(files):
1169
  try:
1170
  results = np.loadtxt(f, usecols=[2, 3, 4, 8, 9, 12, 13, 14, 10, 11], ndmin=2).T
 
1154
  fig.savefig(f.replace('.txt', '.png'), dpi=200)
1155
 
1156
 
1157
+ def plot_results(start=0, stop=0, bucket='', id=(), labels=(), save_dir= '.'): # from utils.utils import *; plot_results()
1158
  # Plot training 'results*.txt' as seen in https://github.com/ultralytics/yolov5#reproduce-our-training
1159
  fig, ax = plt.subplots(2, 5, figsize=(12, 6))
1160
  ax = ax.ravel()
 
1164
  os.system('rm -rf storage.googleapis.com')
1165
  files = ['https://storage.googleapis.com/%s/results%g.txt' % (bucket, x) for x in id]
1166
  else:
1167
+ files = glob.glob(os.path.join(save_dir,'results*.txt')) + glob.glob('../../Downloads/results*.txt')
1168
  for fi, f in enumerate(files):
1169
  try:
1170
  results = np.loadtxt(f, usecols=[2, 3, 4, 8, 9, 12, 13, 14, 10, 11], ndmin=2).T