Label utilities.
Function | classification |
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. |
Function | classifications |
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. |
Function | export |
Exports the semantic segmentations, instance segmentations, or heatmaps stored as in-database arrays in the specified field to images on disk. |
Function | import |
Imports the semantic segmentations, instance segmentations, or heatmaps stored on disk in the specified field to in-database arrays. |
Function | instances |
Converts the instance segmentations in the specified field of the collection into fiftyone.core.labels.Polylines instances. |
Function | objects |
Converts the instance segmentations or polylines in the specified field of the collection into semantic segmentation masks. |
Function | perform |
Performs non-maximum suppression (NMS) on the specified fiftyone.core.labels.Detections field. |
Function | segmentations |
Converts the semantic segmentations masks in the specified field of the collection into fiftyone.core.labels.Detections with instance masks populated. |
Function | segmentations |
Converts the semantic segmentations masks in the specified field of the collection into fiftyone.core.labels.Polylines instances. |
Function | transform |
Transforms the segmentations in the given field according to the provided targets map. |
Function | _perform |
Undocumented |
Function | _transform |
Undocumented |
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 | |
sample | a
fiftyone.core.collections.SampleCollection |
in | the name of the fiftyone.core.labels.Classification
field |
out | the name of the fiftyone.core.labels.Detections
field to populate |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
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 | |
sample | a
fiftyone.core.collections.SampleCollection |
in | the name of the fiftyone.core.labels.Classifications
field |
out | the name of the fiftyone.core.labels.Detections
field to populate |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
Exports the semantic segmentations, instance segmentations, or heatmaps stored as in-database arrays in the specified field to images on disk.
Any labels without in-memory arrays are skipped.
Parameters | |
sample | a
fiftyone.core.collections.SampleCollection |
in | the name of the
fiftyone.core.labels.Segmentation ,
fiftyone.core.labels.Detection ,
fiftyone.core.labels.Detections , or
fiftyone.core.labels.Heatmap field |
output | the directory in which to write the images |
relNone | an optional relative directory to strip from each input
filepath to generate a unique identifier that is joined with
output_dir to generate an output path for each image. This
argument allows for populating nested subdirectories in
output_dir that match the shape of the input paths. The path is
converted to an absolute path (if necessary) via
fiftyone.core.storage.normalize_path |
update:True | whether to delete the arrays from the database |
overwrite:False | whether to delete output_dir prior to exporting if it exists |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
Imports the semantic segmentations, instance segmentations, or heatmaps stored on disk in the specified field to in-database arrays.
Any labels without images on disk are skipped.
Parameters | |
sample | a
fiftyone.core.collections.SampleCollection |
in | the name of the
fiftyone.core.labels.Segmentation ,
fiftyone.core.labels.Detection ,
fiftyone.core.labels.Detections , or
fiftyone.core.labels.Heatmap field |
update:True | whether to delete the image paths from the labels |
deleteFalse | whether to delete any imported images from disk |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
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 | a
fiftyone.core.collections.SampleCollection |
in | the name of the fiftyone.core.labels.Detections
field to convert |
out | the name of the fiftyone.core.labels.Polylines
field to populate |
tolerance: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 |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
Converts the instance segmentations or polylines in the specified field of the collection into semantic segmentation masks.
Parameters | |
sample | a
fiftyone.core.collections.SampleCollection |
in | 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 , and
fiftyone.core.labels.Polylines |
out | the name of the fiftyone.core.labels.Segmentation
field to populate |
maskNone | the (width, height) at which to render the segmentation masks. If not provided, masks will be rendered to match the resolution of each input image |
maskNone | a dict mapping pixel values (2D masks) or RGB hex strings (3D masks) 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 255 |
thickness:1 | the thickness, in pixels, at which to render (non-filled) polylines |
outputNone | an optional output directory in which to write the segmentation images. If none is provided, the segmentations are stored in the database |
relNone | an optional relative directory to strip from each input
filepath to generate a unique identifier that is joined with
output_dir to generate an output path for each segmentation
image. This argument allows for populating nested subdirectories in
output_dir that match the shape of the input paths. The path is
converted to an absolute path (if necessary) via
fiftyone.core.storage.normalize_path |
overwrite:False | whether to delete output_dir prior to exporting if it exists |
saveFalse | whether to store the mask_targets on the dataset |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
Performs non-maximum suppression (NMS) on the specified
fiftyone.core.labels.Detections
field.
NMS is a post-processing technique used in object detection to eliminate duplicate detections and select the most relevant detected objects. This helps reduce false positives.
Parameters | |
sample | a
fiftyone.core.collections.SampleCollection |
in | the name of the fiftyone.core.labels.Detections
field |
outNone | the name of the
fiftyone.core.labels.Detections field to populate. If not
specified, the input field is updated in-place |
iou | an intersection over union (IoU) threshold to use. This determines the minimum overlap required between bounding boxes to be considered duplicates. Bounding boxes with IoU values greater than or equal to this threshold will be suppressed |
confidenceNone | a minimum confidence score required for a detection to be considered valid. Detections with confidence scores lower than this threshold will be discarded |
classwise:True | whether to treat each class label separately (True) or suppress all detections jointly (False) |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
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 | a
fiftyone.core.collections.SampleCollection |
in | the name of the fiftyone.core.labels.Segmentation
field to convert |
out | the name of the
fiftyone.core.labels.Detections field to populate |
maskNone | a dict mapping pixel values (2D masks) or RGB hex strings (3D masks) 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 pixel values |
mask | 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:
|
outputNone | an optional output directory in which to write instance segmentation images. If none is provided, the instance segmentations are stored in the database |
relNone | an optional relative directory to strip from each input
filepath to generate a unique identifier that is joined with
output_dir to generate an output path for each instance
segmentation image. This argument allows for populating nested
subdirectories in output_dir that match the shape of the input
paths. The path is converted to an absolute path (if necessary) via
fiftyone.core.storage.normalize_path |
overwrite:False | whether to delete output_dir prior to exporting if it exists |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
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 | a
fiftyone.core.collections.SampleCollection |
in | the name of the fiftyone.core.labels.Segmentation
field to convert |
out | the name of the
fiftyone.core.labels.Polylines field to populate |
maskNone | a dict mapping pixel values (2D masks) or RGB hex strings (3D masks) 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 pixel values |
mask | 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:
|
tolerance:2 | a tolerance, in pixels, when generating approximate polylines for each region. Typical values are 1-3 pixels |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
Transforms the segmentations in the given field according to the provided targets map.
This method can be used to transform between grayscale and RGB masks, or it can be used to edit the pixel values or colors of masks without changing the number of channels.
Note that any pixel values not in targets_map will be zero in the transformed masks.
Parameters | |
sample | a
fiftyone.core.collections.SampleCollection |
in | the name of the fiftyone.core.labels.Segmentation
field |
targets | a dict mapping existing pixel values (2D masks) or RGB hex strings (3D masks) to new pixel values or RGB hex strings to use. You may convert between grayscale and RGB using this argument |
outputNone | an optional directory in which to write the transformed images |
relNone | an optional relative directory to strip from each input
filepath to generate a unique identifier that is joined with
output_dir to generate an output path for each image. This
argument allows for populating nested subdirectories in
output_dir that match the shape of the input paths. The path is
converted to an absolute path (if necessary) via
fiftyone.core.storage.normalize_path |
update:True | whether to update the mask paths on the instances |
updateFalse | whether to update the mask targets on the dataset to reflect the transformed targets |
overwrite:False | whether to delete output_dir prior to exporting if it exists |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |