This commit is contained in:
552068321@qq.com 2022-11-08 10:50:01 +08:00
parent ee5d09adfe
commit dcc9e75ef1

View File

@ -467,18 +467,14 @@ def train(hyp, opt, device, data_list,id,callbacks): # hyp is path/to/hyp.yaml
# end training -----------------------------------------------------------------------------------------------------
if RANK in {-1, 0}:
LOGGER.info(f'\n{epoch - start_epoch + 1} epochs completed in {(time.time() - t0) / 3600:.3f} hours.')
print('##############',best)
for f in best:
print('##################',f)
if os.path.exists(best):
strip_optimizer(f) # strip optimizers
if f is best:
strip_optimizer(best) # strip optimizers
LOGGER.info(f'\nValidating {f}...')
results, _, _ = validate.run(
data_dict,
batch_size=batch_size // WORLD_SIZE * 2,
imgsz=imgsz,
model=attempt_load(f, device).half(),
model=attempt_load(best, device).half(),
iou_thres=0.65 if is_coco else 0.60, # best pycocotools at iou 0.65
single_cls=single_cls,
dataloader=val_loader,
@ -490,7 +486,6 @@ def train(hyp, opt, device, data_list,id,callbacks): # hyp is path/to/hyp.yaml
compute_loss=compute_loss) # val best model with plots
if is_coco:
callbacks.run('on_fit_epoch_end', list(mloss) + list(results) + lr, epoch, best_fitness, fi)
#callbacks.run('on_train_end', best, epoch, results)
torch.cuda.empty_cache()