tlc.client.torch.metrics.metrics_collectors.segmentation_metrics_collector
¶
Collect metrics for segmentation problems.
Module Contents¶
Classes¶
Class |
Description |
---|---|
Collect predicted masks from model output. |
Data¶
Data |
Description |
---|---|
Key for a column containing predicted masks (Deprecated: use |
API¶
- PREDICTED_MASK_METRIC_NAME = None¶
Key for a column containing predicted masks (Deprecated: use
PREDICTED_MASK
instead)
- class SegmentationMetricsCollector(
- label_map: dict[int, str],
- preprocess_fn: Callable[[tlc.core.builtins.types.SampleData, PredictorOutput], tuple[Any, Any]] | None = None,
Bases:
tlc.client.torch.metrics.metrics_collectors.metrics_collector_base.MetricsCollector
Collect predicted masks from model output.
Predicted masks are converted to PIL images, which can be written to the Run folder by a
MetricsTableWriter
.Initialize the SegmentationMetricsCollector.
- Parameters:
label_map – A dictionary mapping class ids to class labels.
preprocess_fn – A function that pre-processes the model output before computing metrics.
- compute_metrics(
- batch: tlc.core.builtins.types.SampleData,
- predictor_output: PredictorOutput,
Convert predicted masks from model output to PIL images.
The result of preprocessing the model output is expected to be a list of tensors.
- Parameters:
batch – The input batch (not used).
predictor_output – The output from the Predictor.
- Returns:
A batch of metrics, where each metric is a PIL image corresponding to a mask.
- preprocess(
- batch: tlc.core.builtins.types.SampleData,
- predictor_output: PredictorOutput,
Default preprocessor for segmentation output.
By default just forwards the model predictions.
- Parameters:
batch – A batch of samples.
predictor_output – A batch of predictions.
- Returns:
A tuple containing the preprocessed batch and predictions.