updates
This commit is contained in:
parent
fff60c651a
commit
e9437b2178
9
train.py
9
train.py
|
@ -18,6 +18,7 @@ except:
|
||||||
wdir = 'weights' + os.sep # weights dir
|
wdir = 'weights' + os.sep # weights dir
|
||||||
last = wdir + 'last.pt'
|
last = wdir + 'last.pt'
|
||||||
best = wdir + 'best.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
|
# 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
|
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)
|
save_json=final_epoch and epoch > 0 and 'coco.data' in data)
|
||||||
|
|
||||||
# Write epoch results
|
# Write epoch results
|
||||||
with open('results.txt', 'a') as file:
|
with open(results_file, 'a') as f:
|
||||||
file.write(s + '%10.3g' * 7 % results + '\n') # P, R, mAP, F1, test_losses=(GIoU, obj, cls)
|
f.write(s + '%10.3g' * 7 % results + '\n') # P, R, mAP, F1, test_losses=(GIoU, obj, cls)
|
||||||
|
|
||||||
# Write Tensorboard results
|
# Write Tensorboard results
|
||||||
if tb_writer:
|
if tb_writer:
|
||||||
|
@ -331,11 +332,11 @@ def train():
|
||||||
# Save training results
|
# Save training results
|
||||||
save = (not opt.nosave) or (final_epoch and not opt.evolve) or opt.prebias
|
save = (not opt.nosave) or (final_epoch and not opt.evolve) or opt.prebias
|
||||||
if save:
|
if save:
|
||||||
with open('results.txt', 'r') as file:
|
with open(results_file, 'r') as f:
|
||||||
# Create checkpoint
|
# Create checkpoint
|
||||||
chkpt = {'epoch': epoch,
|
chkpt = {'epoch': epoch,
|
||||||
'best_fitness': best_fitness,
|
'best_fitness': best_fitness,
|
||||||
'training_results': file.read(),
|
'training_results': f.read(),
|
||||||
'model': model.module.state_dict() if type(
|
'model': model.module.state_dict() if type(
|
||||||
model) is nn.parallel.DistributedDataParallel else model.state_dict(),
|
model) is nn.parallel.DistributedDataParallel else model.state_dict(),
|
||||||
'optimizer': None if final_epoch else optimizer.state_dict()}
|
'optimizer': None if final_epoch else optimizer.state_dict()}
|
||||||
|
|
Loading…
Reference in New Issue