From c9a46a60e09ab94009754ca71bde23e91aab33fe Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 14 Dec 2021 15:47:49 +0100 Subject: [PATCH] Update callbacks.py with `__init__()` (#5979) Add __init__() function. --- utils/callbacks.py | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) 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): """