|
|
@@ -346,24 +346,24 @@ def train(hyp, tb_writer, opt, device): |
|
|
|
dataloader=testloader, |
|
|
|
save_dir=log_dir) |
|
|
|
|
|
|
|
# Write |
|
|
|
with open(results_file, 'a') as f: |
|
|
|
f.write(s + '%10.4g' * 7 % results + '\n') # P, R, mAP, F1, test_losses=(GIoU, obj, cls) |
|
|
|
if len(opt.name) and opt.bucket: |
|
|
|
os.system('gsutil cp %s gs://%s/results/results%s.txt' % (results_file, opt.bucket, opt.name)) |
|
|
|
|
|
|
|
# Tensorboard |
|
|
|
if tb_writer: |
|
|
|
tags = ['train/giou_loss', 'train/obj_loss', 'train/cls_loss', |
|
|
|
'metrics/precision', 'metrics/recall', 'metrics/mAP_0.5', 'metrics/mAP_0.5:0.95', |
|
|
|
'val/giou_loss', 'val/obj_loss', 'val/cls_loss'] |
|
|
|
for x, tag in zip(list(mloss[:-1]) + list(results), tags): |
|
|
|
tb_writer.add_scalar(tag, x, epoch) |
|
|
|
|
|
|
|
# Update best mAP |
|
|
|
fi = fitness(np.array(results).reshape(1, -1)) # fitness_i = weighted combination of [P, R, mAP, F1] |
|
|
|
if fi > best_fitness: |
|
|
|
best_fitness = fi |
|
|
|
# Write |
|
|
|
with open(results_file, 'a') as f: |
|
|
|
f.write(s + '%10.4g' * 7 % results + '\n') # P, R, mAP, F1, test_losses=(GIoU, obj, cls) |
|
|
|
if len(opt.name) and opt.bucket: |
|
|
|
os.system('gsutil cp %s gs://%s/results/results%s.txt' % (results_file, opt.bucket, opt.name)) |
|
|
|
|
|
|
|
# Tensorboard |
|
|
|
if tb_writer: |
|
|
|
tags = ['train/giou_loss', 'train/obj_loss', 'train/cls_loss', |
|
|
|
'metrics/precision', 'metrics/recall', 'metrics/mAP_0.5', 'metrics/mAP_0.5:0.95', |
|
|
|
'val/giou_loss', 'val/obj_loss', 'val/cls_loss'] |
|
|
|
for x, tag in zip(list(mloss[:-1]) + list(results), tags): |
|
|
|
tb_writer.add_scalar(tag, x, epoch) |
|
|
|
|
|
|
|
# Update best mAP |
|
|
|
fi = fitness(np.array(results).reshape(1, -1)) # fitness_i = weighted combination of [P, R, mAP, F1] |
|
|
|
if fi > best_fitness: |
|
|
|
best_fitness = fi |
|
|
|
|
|
|
|
# Save model |
|
|
|
save = (not opt.nosave) or (final_epoch and not opt.evolve) |