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

View File

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