# fiftyone.utils.labels¶

Label utilities.

Functions:

 Converts the fiftyone.core.labels.Classification field of the collection into a fiftyone.core.labels.Detections field containing a single detection whose bounding box spans the entire image. Converts the fiftyone.core.labels.Classifications field of the collection into a fiftyone.core.labels.Detections field containing detections whose bounding boxes span the entire image with one detection for each classification. instances_to_polylines(sample_collection, …) Converts the instance segmentations in the specified field of the collection into fiftyone.core.labels.Polylines instances. objects_to_segmentations(sample_collection, …) Converts the instance segmentations or polylines in the specified field of the collection into semantic segmentation masks. Converts the semantic segmentations masks in the specified field of the collection into fiftyone.core.labels.Detections with instance masks populated. Converts the semantic segmentations masks in the specified field of the collection into fiftyone.core.labels.Polylines instances.
fiftyone.utils.labels.objects_to_segmentations(sample_collection, in_field, out_field, mask_size=None, mask_targets=None, thickness=1)

Converts the instance segmentations or polylines in the specified field of the collection into semantic segmentation masks.

Parameters
fiftyone.utils.labels.segmentations_to_detections(sample_collection, in_field, out_field, mask_targets=None, mask_types='stuff')

Converts the semantic segmentations masks in the specified field of the collection into fiftyone.core.labels.Detections with instance masks populated.

Each "stuff" class will be converted to a single fiftyone.core.labels.Detection whose instance mask spans all region(s) of the class.

Each "thing" class will result in one fiftyone.core.labels.Detection instance per connected region of that class in the segmentation.

Parameters
• sample_collection – a fiftyone.core.collections.SampleCollection

• in_field – the name of the fiftyone.core.labels.Segmentation field to convert

• out_field – the name of the fiftyone.core.labels.Detections field to populate

• mask_targets (None) – a dict mapping integer pixel values in [0, 255] to label strings defining which object classes to label and which pixel values to use for each class. If omitted, all labels are assigned to the integer pixel values

whether the classes are "stuff" (amorphous regions of pixels) or "thing" (connected regions, each representing an instance of the thing). Can be any of the following:

• "stuff" if all classes are stuff classes

• "thing" if all classes are thing classes

• a dict mapping pixel values to "stuff" or "thing" for each class

fiftyone.utils.labels.instances_to_polylines(sample_collection, in_field, out_field, tolerance=2, filled=True)

Converts the instance segmentations in the specified field of the collection into fiftyone.core.labels.Polylines instances.

For detections with masks, the returned polylines will trace the boundaries of the masks; otherwise, the polylines will trace the bounding boxes themselves.

Parameters
fiftyone.utils.labels.segmentations_to_polylines(sample_collection, in_field, out_field, mask_targets=None, mask_types='stuff', tolerance=2)

Converts the semantic segmentations masks in the specified field of the collection into fiftyone.core.labels.Polylines instances.

Each "stuff" class will be converted to a single fiftyone.core.labels.Polylines that may contain multiple disjoint shapes capturing the class.

Each "thing" class will result in one fiftyone.core.labels.Polylines instance per connected region of that class.

Parameters
• sample_collection – a fiftyone.core.collections.SampleCollection

• in_field – the name of the fiftyone.core.labels.Segmentation field to convert

• out_field – the name of the fiftyone.core.labels.Polylines field to populate

• mask_targets (None) – a dict mapping integer pixel values in [0, 255] to label strings defining which object classes to label and which pixel values to use for each class. If omitted, all labels are assigned to the integer pixel values

whether the classes are "stuff" (amorphous regions of pixels) or "thing" (connected regions, each representing an instance of the thing). Can be any of the following:

• "stuff" if all classes are stuff classes

• "thing" if all classes are thing classes

• a dict mapping pixel values to "stuff" or "thing" for each class

• tolerance (2) – a tolerance, in pixels, when generating approximate polylines for each region. Typical values are 1-3 pixels

fiftyone.utils.labels.classification_to_detections(sample_collection, in_field, out_field)

Converts the fiftyone.core.labels.Classification field of the collection into a fiftyone.core.labels.Detections field containing a single detection whose bounding box spans the entire image.

Parameters
fiftyone.utils.labels.classifications_to_detections(sample_collection, in_field, out_field)

Converts the fiftyone.core.labels.Classifications field of the collection into a fiftyone.core.labels.Detections field containing detections whose bounding boxes span the entire image with one detection for each classification.

Parameters