def_log_images(imgs_dict,group=''):"""Log scalars to the NeptuneAI experiment logger."""ifrun:fork,vinimgs_dict.items():run[f'{group}/{k}'].upload(File(v))
_log_plot
Log plots to the NeptuneAI experiment logger.
Source code in ultralytics/yolo/utils/callbacks/neptune.py
def_log_plot(title,plot_path):"""Log plots to the NeptuneAI experiment logger."""""" Log image as plot in the plot section of NeptuneAI arguments: title (str) Title of the plot plot_path (PosixPath or str) Path to the saved image file """img=mpimg.imread(plot_path)fig=plt.figure()ax=fig.add_axes([0,0,1,1],frameon=False,aspect='auto',xticks=[],yticks=[])# no ticksax.imshow(img)run[f'Plots/{title}'].upload(fig)
on_pretrain_routine_start
Callback function called before the training routine starts.
Source code in ultralytics/yolo/utils/callbacks/neptune.py
defon_pretrain_routine_start(trainer):"""Callback function called before the training routine starts."""try:globalrunrun=neptune.init_run(project=trainer.args.projector'YOLOv8',name=trainer.args.name,tags=['YOLOv8'])run['Configuration/Hyperparameters']={k:''ifvisNoneelsevfork,vinvars(trainer.args).items()}exceptExceptionase:LOGGER.warning(f'WARNING ⚠️ NeptuneAI installed but not initialized correctly, not logging this run. {e}')
on_train_epoch_end
Callback function called at end of each training epoch.
Source code in ultralytics/yolo/utils/callbacks/neptune.py
defon_train_epoch_end(trainer):"""Callback function called at end of each training epoch."""_log_scalars(trainer.label_loss_items(trainer.tloss,prefix='train'),trainer.epoch+1)_log_scalars(trainer.lr,trainer.epoch+1)iftrainer.epoch==1:_log_images({f.stem:str(f)forfintrainer.save_dir.glob('train_batch*.jpg')},'Mosaic')
on_fit_epoch_end
Callback function called at end of each fit (train+val) epoch.
Source code in ultralytics/yolo/utils/callbacks/neptune.py
defon_fit_epoch_end(trainer):"""Callback function called at end of each fit (train+val) epoch."""ifrunandtrainer.epoch==0:run['Configuration/Model']=model_info_for_loggers(trainer)_log_scalars(trainer.metrics,trainer.epoch+1)
on_val_end
Callback function called at end of each validation.
Source code in ultralytics/yolo/utils/callbacks/neptune.py
defon_val_end(validator):"""Callback function called at end of each validation."""ifrun:# Log val_labels and val_pred_log_images({f.stem:str(f)forfinvalidator.save_dir.glob('val*.jpg')},'Validation')
on_train_end
Callback function called at end of training.
Source code in ultralytics/yolo/utils/callbacks/neptune.py
defon_train_end(trainer):"""Callback function called at end of training."""ifrun:# Log final results, CM matrix + PR plotsfiles=['results.png','confusion_matrix.png','confusion_matrix_normalized.png',*(f'{x}_curve.png'forxin('F1','PR','P','R'))]files=[(trainer.save_dir/f)forfinfilesif(trainer.save_dir/f).exists()]# filterforfinfiles:_log_plot(title=f.stem,plot_path=f)# Log the final modelrun[f'weights/{trainer.args.nameortrainer.args.task}/{str(trainer.best.name)}'].upload(File(str(trainer.best)))run.stop()
Created 2023-04-29, Updated 2023-05-17 Authors: Glenn Jocher (3)