Skip to content

frameworks.ultralytics.services.model.logger.object_detection

object_detection

Classes:

Name Description
UltralyticsObjectDetectionMetricMapping

Defines the metric mapping for object detection tasks using the Ultralytics framework.

UltralyticsObjectDetectionLogger

Logger for Ultralytics-based object detection models.

UltralyticsObjectDetectionMetricMapping()

Bases: UltralyticsBaseMetricMapping

Defines the metric mapping for object detection tasks using the Ultralytics framework.

This mapping class registers framework-specific metric names and their corresponding standard names for both training and validation phases. It includes loss components, label metrics, and evaluation metrics.

Sets up metric associations for box loss, classification loss, distribution focal loss (DFL), precision, recall, and mAP values.

Methods:

Name Description
add_metric

Add a metric to the specified phase.

get_mapping

Get mapping of framework names to standard names for a given phase.

Attributes:

Name Type Description
mappings dict[str, list[Metric]]

mappings = {'train': [], 'val': [], 'test': []} instance-attribute

add_metric(phase, metric)

Add a metric to the specified phase.

Parameters:

Name Type Description Default
phase
str

One of 'train', 'val', or 'test'.

required
metric
Metric

The metric to register.

required

get_mapping(phase=None)

Get mapping of framework names to standard names for a given phase.

Parameters:

Name Type Description Default
phase
str | None

One of 'train', 'val', 'test'.

None

Returns:

Name Type Description
dict dict[str, str]

Mapping of metric names.

UltralyticsObjectDetectionLogger(experiment, metric_mapping)

Bases: BaseLogger

Logger for Ultralytics-based object detection models.

This logger uses an UltralyticsObjectDetectionMetricMapping to normalize metric names and logs them to a Picsellia experiment during training and validation phases.

Parameters:

Name Type Description Default

experiment

Experiment

The experiment object used for logging.

required

metric_mapping

UltralyticsObjectDetectionMetricMapping

Mapping for translating framework-specific metrics.

required

Methods:

Name Description
log_metric

Log a metric value (e.g. for line plot).

log_value

Log a scalar value (e.g., accuracy score).

log_image

Log an image file.

log_confusion_matrix

Log a confusion matrix as a heatmap.

log_table

Log a table (either a key-value dict or 2D matrix).

get_log_name

Construct log name with optional phase and mapped name.

Attributes:

Name Type Description
experiment
metric_mapping

experiment = experiment instance-attribute

metric_mapping = metric_mapping instance-attribute

log_metric(name, value, log_type=LogType.LINE, phase=None)

Log a metric value (e.g. for line plot).

Parameters:

Name Type Description Default
name
str

Metric name.

required
value
float

Metric value.

required
log_type
LogType

Logging type (default LINE).

LINE
phase
str | None

Phase name.

None

log_value(name, value, phase=None, precision=4)

Log a scalar value (e.g., accuracy score).

Parameters:

Name Type Description Default
name
str

Metric name.

required
value
float

Value to log.

required
phase
str | None

Phase name.

None
precision
int

Decimal precision to round.

4

log_image(name, image_path, phase=None)

Log an image file.

Parameters:

Name Type Description Default
name
str

Log name.

required
image_path
str

Path to image.

required
phase
str | None

Phase name.

None

log_confusion_matrix(name, labelmap, matrix, phase=None)

Log a confusion matrix as a heatmap.

Parameters:

Name Type Description Default
name
str

Log name.

required
labelmap
dict

Mapping of label indices to names.

required
matrix
ndarray

Confusion matrix.

required
phase
str | None

Phase name.

None

log_table(name, data, phase=None)

Log a table (either a key-value dict or 2D matrix).

Parameters:

Name Type Description Default
name
str

Log name.

required
data
dict

Data to log.

required
phase
str | None

Phase name.

None

get_log_name(metric_name, phase=None)

Construct log name with optional phase and mapped name.

Parameters:

Name Type Description Default
metric_name
str

Base metric name.

required
phase
str | None

Optional phase.

None

Returns:

Name Type Description
str str

Full log name.