Update callbacks.py with `__init__()` (#5979)
Browse files- utils/callbacks.py +22 -21
utils/callbacks.py
CHANGED
@@ -9,31 +9,32 @@ class Callbacks:
|
|
9 |
Handles all registered callbacks for YOLOv5 Hooks
|
10 |
"""
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
|
37 |
|
38 |
def register_action(self, hook, name='', callback=None):
|
39 |
"""
|
|
|
9 |
Handles all registered callbacks for YOLOv5 Hooks
|
10 |
"""
|
11 |
|
12 |
+
def __init__(self):
|
13 |
+
# Define the available callbacks
|
14 |
+
self._callbacks = {
|
15 |
+
'on_pretrain_routine_start': [],
|
16 |
+
'on_pretrain_routine_end': [],
|
17 |
|
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': [],
|
25 |
|
26 |
+
'on_val_start': [],
|
27 |
+
'on_val_batch_start': [],
|
28 |
+
'on_val_image_end': [],
|
29 |
+
'on_val_batch_end': [],
|
30 |
+
'on_val_end': [],
|
31 |
|
32 |
+
'on_fit_epoch_end': [], # fit = train + val
|
33 |
+
'on_model_save': [],
|
34 |
+
'on_train_end': [],
|
35 |
|
36 |
+
'teardown': [],
|
37 |
+
}
|
38 |
|
39 |
def register_action(self, hook, name='', callback=None):
|
40 |
"""
|