frameworks.ultralytics.services.model.callbacks¶
callbacks
¶
Classes:
Name | Description |
---|---|
UltralyticsCallbacks |
Provides callback hooks for training and evaluation lifecycle events in Ultralytics YOLO models. |
Functions:
Name | Description |
---|---|
extract_column_names |
Parses a YOLO-style descriptor string to extract column names, preserving prefixes like 'Box' and 'Mask'. |
log_confusion_matrix |
|
UltralyticsCallbacks(experiment, logger, metric_mapping, model, save_period)
¶
Provides callback hooks for training and evaluation lifecycle events in Ultralytics YOLO models.
This class integrates with Picsellia to log metrics, images, and artifacts during the training and validation process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Experiment
|
The experiment object used for logging. |
required |
|
type[TBaseLogger]
|
The logger class used for metric/image logging. |
required |
|
TMetricMapping
|
Maps framework-specific metric names to standard names. |
required |
|
UltralyticsModel
|
The model wrapper to manage artifacts and paths. |
required |
|
int
|
Frequency (in epochs) to save model checkpoints. |
required |
Methods:
Name | Description |
---|---|
on_train_epoch_end |
Callback called at the end of each training epoch. |
on_fit_epoch_end |
Callback called at the end of each epoch (after validation). |
on_val_end |
Callback called after validation. |
on_train_end |
Callback called at the end of training. |
get_callbacks |
Returns the dictionary of callback methods for integration into the Ultralytics engine. |
Attributes:
Name | Type | Description |
---|---|---|
experiment |
|
|
model |
|
|
save_period |
|
experiment = experiment
instance-attribute
¶
model = model
instance-attribute
¶
save_period = save_period
instance-attribute
¶
on_train_epoch_end(trainer)
¶
Callback called at the end of each training epoch. Logs training and validation losses, learning rates, and periodically saves the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
TBaseTrainer
|
The trainer object with training state and losses. |
required |
on_fit_epoch_end(trainer)
¶
Callback called at the end of each epoch (after validation). Logs time, metrics, and training images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
TBaseTrainer
|
The trainer object with metrics and epoch info. |
required |
on_val_end(validator)
¶
Callback called after validation. Logs validation result images and performance metrics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
TBaseValidator
|
The validator object with validation metrics. |
required |
on_train_end(trainer)
¶
Callback called at the end of training. Currently logs final metrics (disabled by default).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
TBaseTrainer
|
The trainer object. |
required |
get_callbacks()
¶
Returns the dictionary of callback methods for integration into the Ultralytics engine.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, Callable]
|
Callback function names mapped to their handlers. |
extract_column_names(desc)
¶
Parses a YOLO-style descriptor string to extract column names, preserving prefixes like 'Box' and 'Mask'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
A description string (e.g., "Class Images Instances Box(P R mAP50)"). |
required |
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: Parsed column names (e.g., ["Class", "Images", "Instances", "Box(P)", ...]). |