Update callbacks.py with __init__() (#5979)

Add __init__() function.
This commit is contained in:
Glenn Jocher 2021-12-14 15:47:49 +01:00 committed by GitHub
parent d699c21c75
commit c9a46a60e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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