Skip to content

Commit 0a86a15

Browse files
authored
Update callbacks.py with __init__() (ultralytics#5979)
Add __init__() function.
1 parent 6bc585d commit 0a86a15

1 file changed

Lines changed: 22 additions & 21 deletions

File tree

utils/callbacks.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,32 @@ class Callbacks:
99
Handles all registered callbacks for YOLOv5 Hooks
1010
"""
1111

12-
# Define the available callbacks
13-
_callbacks = {
14-
'on_pretrain_routine_start': [],
15-
'on_pretrain_routine_end': [],
12+
def __init__(self):
13+
# Define the available callbacks
14+
self._callbacks = {
15+
'on_pretrain_routine_start': [],
16+
'on_pretrain_routine_end': [],
1617

17-
'on_train_start': [],
18-
'on_train_epoch_start': [],
19-
'on_train_batch_start': [],
20-
'optimizer_step': [],
21-
'on_before_zero_grad': [],
22-
'on_train_batch_end': [],
23-
'on_train_epoch_end': [],
18+
'on_train_start': [],
19+
'on_train_epoch_start': [],
20+
'on_train_batch_start': [],
21+
'optimizer_step': [],
22+
'on_before_zero_grad': [],
23+
'on_train_batch_end': [],
24+
'on_train_epoch_end': [],
2425

25-
'on_val_start': [],
26-
'on_val_batch_start': [],
27-
'on_val_image_end': [],
28-
'on_val_batch_end': [],
29-
'on_val_end': [],
26+
'on_val_start': [],
27+
'on_val_batch_start': [],
28+
'on_val_image_end': [],
29+
'on_val_batch_end': [],
30+
'on_val_end': [],
3031

31-
'on_fit_epoch_end': [], # fit = train + val
32-
'on_model_save': [],
33-
'on_train_end': [],
32+
'on_fit_epoch_end': [], # fit = train + val
33+
'on_model_save': [],
34+
'on_train_end': [],
3435

35-
'teardown': [],
36-
}
36+
'teardown': [],
37+
}
3738

3839
def register_action(self, hook, name='', callback=None):
3940
"""

0 commit comments

Comments
 (0)