This commit is contained in:
Glenn Jocher 2019-09-18 00:54:07 +02:00
parent fff60c651a
commit e9437b2178
1 changed files with 5 additions and 4 deletions

View File

@ -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()}