diff --git a/utils/callbacks.py b/utils/callbacks.py index 327b8639b60c..c9d936ef082d 100644 --- a/utils/callbacks.py +++ b/utils/callbacks.py @@ -9,31 +9,32 @@ class Callbacks: Handles all registered callbacks for YOLOv5 Hooks """ - # Define the available callbacks - _callbacks = { - 'on_pretrain_routine_start': [], - 'on_pretrain_routine_end': [], + def __init__(self): + # Define the available callbacks + self._callbacks = { + 'on_pretrain_routine_start': [], + 'on_pretrain_routine_end': [], - 'on_train_start': [], - 'on_train_epoch_start': [], - 'on_train_batch_start': [], - 'optimizer_step': [], - 'on_before_zero_grad': [], - 'on_train_batch_end': [], - 'on_train_epoch_end': [], + 'on_train_start': [], + 'on_train_epoch_start': [], + 'on_train_batch_start': [], + 'optimizer_step': [], + 'on_before_zero_grad': [], + 'on_train_batch_end': [], + 'on_train_epoch_end': [], - 'on_val_start': [], - 'on_val_batch_start': [], - 'on_val_image_end': [], - 'on_val_batch_end': [], - 'on_val_end': [], + 'on_val_start': [], + 'on_val_batch_start': [], + 'on_val_image_end': [], + 'on_val_batch_end': [], + 'on_val_end': [], - 'on_fit_epoch_end': [], # fit = train + val - 'on_model_save': [], - 'on_train_end': [], + 'on_fit_epoch_end': [], # fit = train + val + 'on_model_save': [], + 'on_train_end': [], - 'teardown': [], - } + 'teardown': [], + } def register_action(self, hook, name='', callback=None): """