Skip to content

frameworks.ultralytics.services.model.logger.segmentation

segmentation

Classes:

Name Description
UltralyticsSegmentationMetricMapping

Defines the metric mapping for segmentation tasks using the Ultralytics framework.

UltralyticsSegmentationLogger

Logger for Ultralytics-based segmentation models.

UltralyticsSegmentationMetricMapping()

Bases: UltralyticsObjectDetectionMetricMapping

Defines the metric mapping for segmentation tasks using the Ultralytics framework.

This class extends the object detection mapping and adds segmentation-specific metrics, such as segmentation loss and mask-based precision, recall, and mAP.

Adds metrics for training and validation segmentation loss, as well as mask precision, recall, mAP50, and mAP50-95.

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.

UltralyticsSegmentationLogger(experiment, metric_mapping)

Bases: BaseLogger

Logger for Ultralytics-based segmentation models.

This logger uses an UltralyticsSegmentationMetricMapping to log metrics during training and validation phases to a Picsellia experiment.

Parameters:

Name Type Description Default

experiment

Experiment

The experiment used for logging.

required

metric_mapping

UltralyticsSegmentationMetricMapping

The segmentation-specific metric mapping.

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.