From e9437b2178b9a8fd2e01f30af91d17d339c8be94 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 18 Sep 2019 00:54:07 +0200 Subject: [PATCH] updates --- train.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/train.py b/train.py index b1921790..0b22c019 100644 --- a/train.py +++ b/train.py @@ -18,6 +18,7 @@ except: wdir = 'weights' + os.sep # weights dir last = wdir + 'last.pt' best = wdir + 'best.pt' +results_file = 'results.txt' # Hyperparameters (j-series, 50.5 mAP yolov3-320) evolved by @ktian08 https://github.com/ultralytics/yolov3/issues/310 hyp = {'giou': 1.582, # giou loss gain @@ -312,8 +313,8 @@ def train(): save_json=final_epoch and epoch > 0 and 'coco.data' in data) # Write epoch results - with open('results.txt', 'a') as file: - file.write(s + '%10.3g' * 7 % results + '\n') # P, R, mAP, F1, test_losses=(GIoU, obj, cls) + with open(results_file, 'a') as f: + f.write(s + '%10.3g' * 7 % results + '\n') # P, R, mAP, F1, test_losses=(GIoU, obj, cls) # Write Tensorboard results if tb_writer: @@ -331,11 +332,11 @@ def train(): # Save training results save = (not opt.nosave) or (final_epoch and not opt.evolve) or opt.prebias if save: - with open('results.txt', 'r') as file: + with open(results_file, 'r') as f: # Create checkpoint chkpt = {'epoch': epoch, 'best_fitness': best_fitness, - 'training_results': file.read(), + 'training_results': f.read(), 'model': model.module.state_dict() if type( model) is nn.parallel.DistributedDataParallel else model.state_dict(), 'optimizer': None if final_epoch else optimizer.state_dict()}