fiftyone.utils.labels¶
Label utilities.
Functions:
Converts the |
|
Converts the |
|
|
Converts the instance segmentations in the specified field of the collection into |
|
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 |
|
Converts the semantic segmentations masks in the specified field of the collection into |
-
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
sample_collection – a
fiftyone.core.collections.SampleCollection
in_field – the name of the objects field for which to render segmentation masks. Supported types are
fiftyone.core.labels.Detection
,fiftyone.core.labels.Detections
,fiftyone.core.labels.Polyline
, andfiftyone.core.labels.Polylines
out_field – the name of the
fiftyone.core.labels.Segmentation
field to populatemask_size (None) – the
(width, height)
at which to render the segmentation masks. If not provided, masks will be rendered to match the resolution of each input imagemask_targets (None) – a dict mapping integer pixel values in
[0, 255]
to label strings defining which object classes to render and which pixel values to use for each class. If omitted, all objects are rendered with pixel value 255thickness (1) – the thickness, in pixels, at which to render (non-filled) polylines
-
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 singlefiftyone.core.labels.Detection
whose instance mask spans all region(s) of the class.Each
"thing"
class will result in onefiftyone.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 convertout_field – the name of the
fiftyone.core.labels.Detections
field to populatemask_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 valuesmask_types ("stuff") –
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 classesa 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
sample_collection – a
fiftyone.core.collections.SampleCollection
in_field – the name of the
fiftyone.core.labels.Detections
field to convertout_field – the name of the
fiftyone.core.labels.Polylines
field to populatetolerance (2) – a tolerance, in pixels, when generating approximate polylines for each region. Typical values are 1-3 pixels
filled (True) – whether the polylines should be filled
-
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 singlefiftyone.core.labels.Polylines
that may contain multiple disjoint shapes capturing the class.Each
"thing"
class will result in onefiftyone.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 convertout_field – the name of the
fiftyone.core.labels.Polylines
field to populatemask_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 valuesmask_types ("stuff") –
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 classesa 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 afiftyone.core.labels.Detections
field containing a single detection whose bounding box spans the entire image.- Parameters
sample_collection – a
fiftyone.core.collections.SampleCollection
in_field – the name of the
fiftyone.core.labels.Classification
fieldout_field – the name of the
fiftyone.core.labels.Detections
field to populate
-
fiftyone.utils.labels.
classifications_to_detections
(sample_collection, in_field, out_field)¶ Converts the
fiftyone.core.labels.Classifications
field of the collection into afiftyone.core.labels.Detections
field containing detections whose bounding boxes span the entire image with one detection for each classification.- Parameters
sample_collection – a
fiftyone.core.collections.SampleCollection
in_field – the name of the
fiftyone.core.labels.Classifications
fieldout_field – the name of the
fiftyone.core.labels.Detections
field to populate