Reference for ultralytics/utils/callbacks/wb.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/callbacks/wb.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.utils.callbacks.wb._custom_table
_custom_table(
x,
y,
classes,
title="Precision Recall Curve",
x_title="Recall",
y_title="Precision",
)
Create and log a custom metric visualization to wandb.plot.pr_curve.
This function crafts a custom metric visualization that mimics the behavior of the default wandb precision-recall curve while allowing for enhanced customization. The visual metric is useful for monitoring model performance across different classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | List | Values for the x-axis; expected to have length N. | required |
y | List | Corresponding values for the y-axis; also expected to have length N. | required |
classes | List | Labels identifying the class of each point; length N. | required |
title | str | Title for the plot; defaults to 'Precision Recall Curve'. | 'Precision Recall Curve' |
x_title | str | Label for the x-axis; defaults to 'Recall'. | 'Recall' |
y_title | str | Label for the y-axis; defaults to 'Precision'. | 'Precision' |
Returns:
Type | Description |
---|---|
Object | A wandb object suitable for logging, showcasing the crafted metric visualization. |
Source code in ultralytics/utils/callbacks/wb.py
ultralytics.utils.callbacks.wb._plot_curve
_plot_curve(
x,
y,
names=None,
id="precision-recall",
title="Precision Recall Curve",
x_title="Recall",
y_title="Precision",
num_x=100,
only_mean=False,
)
Log a metric curve visualization.
This function generates a metric curve based on input data and logs the visualization to wandb. The curve can represent aggregated data (mean) or individual class data, depending on the 'only_mean' flag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | ndarray | Data points for the x-axis with length N. | required |
y | ndarray | Corresponding data points for the y-axis with shape CxN, where C is the number of classes. | required |
names | list | Names of the classes corresponding to the y-axis data; length C. Defaults to []. | None |
id | str | Unique identifier for the logged data in wandb. Defaults to 'precision-recall'. | 'precision-recall' |
title | str | Title for the visualization plot. Defaults to 'Precision Recall Curve'. | 'Precision Recall Curve' |
x_title | str | Label for the x-axis. Defaults to 'Recall'. | 'Recall' |
y_title | str | Label for the y-axis. Defaults to 'Precision'. | 'Precision' |
num_x | int | Number of interpolated data points for visualization. Defaults to 100. | 100 |
only_mean | bool | Flag to indicate if only the mean curve should be plotted. Defaults to True. | False |
Note
The function leverages the '_custom_table' function to generate the actual visualization.
Source code in ultralytics/utils/callbacks/wb.py
ultralytics.utils.callbacks.wb._log_plots
Logs plots from the input dictionary if they haven't been logged already at the specified step.
Source code in ultralytics/utils/callbacks/wb.py
ultralytics.utils.callbacks.wb.on_pretrain_routine_start
Initiate and start project if module is present.
Source code in ultralytics/utils/callbacks/wb.py
ultralytics.utils.callbacks.wb.on_fit_epoch_end
Logs training metrics and model information at the end of an epoch.
Source code in ultralytics/utils/callbacks/wb.py
ultralytics.utils.callbacks.wb.on_train_epoch_end
Log metrics and save images at the end of each training epoch.
Source code in ultralytics/utils/callbacks/wb.py
ultralytics.utils.callbacks.wb.on_train_end
Save the best model as an artifact at end of training.