fiftyone.core.annotation.utils#

Annotation utils

Copyright 2017-2026, Voxel51, Inc.

Functions:

ensure_collection_is_supported(sample_collection)

Ensure a fiftyone.core.collections.SampleCollection is supported by the App for annotation.

get_supported_app_annotation_fields(...)

Gets the supported App annotation fields for a fiftyone.core.collections.SampleCollection.

list_valid_annotation_fields(sample_collection)

Lists all valid annotation fields for a fiftyone.core.collections.SampleCollection.

backfill_instances_from_index(sample_collection)

Populates the instance attribute from a legacy index attribute for any of the given track label fields that have index values but no instance values yet.

flatten_fields(collection,ย fields[,ย ...])

Flattens embedded document fields into dot-separated paths.

get_type(field)

Get the type of a field for a label schema

fiftyone.core.annotation.utils.ensure_collection_is_supported(sample_collection)#

Ensure a fiftyone.core.collections.SampleCollection is supported by the App for annotation.

Args:
sample_collection: a

fiftyone.core.collections.SampleCollection

fiftyone.core.annotation.utils.get_supported_app_annotation_fields(sample_collection)#

Gets the supported App annotation fields for a fiftyone.core.collections.SampleCollection.

Currently supported media types for the collection are image and 3d. See fiftyone.core.collections.SampleCollection.media_type

All supported primitive and embedded.document primitives are supported as documented in generate_label_schemas()

The below fiftyone.core.labels.Label types are also resolved.

Supported image fiftyone.core.labels.Label types are:
Supported 3d label types are:
Parameters:

sample_collection โ€“ a fiftyone.core.collections.SampleCollection

Returns:

a list of supported fields

fiftyone.core.annotation.utils.list_valid_annotation_fields(sample_collection, require_app_support=False, flatten=False, include_frames=False)#

Lists all valid annotation fields for a fiftyone.core.collections.SampleCollection.

A field may be valid, but not yet supported by the App for human annotation.

Parameters:
  • sample_collection โ€“ a fiftyone.core.collections.SampleCollection

  • require_app_support (False) โ€“ whether to only include fields supported by the App for annotation

  • flatten (False) โ€“ whether to flatten embedded documents with dot.notation

  • include_frames (False) โ€“ whether to also include valid per-frame label fields, keyed by their frames.<field> path

Returns:

a sorted list of valid annotation field names

fiftyone.core.annotation.utils.backfill_instances_from_index(sample_collection, fields=None)#

Populates the instance attribute from a legacy index attribute for any of the given track label fields that have index values but no instance values yet.

Lets datasets whose tracks are defined by index (rather than instance) be recognized as tracks during a scan. Fields that already have any instance values are left untouched, so existing tracks are never clobbered and the operation is idempotent.

Parameters:
  • sample_collection โ€“ a fiftyone.core.collections.SampleCollection

  • fields (None) โ€“ a field name or iterable of field names to process. By default, all valid annotation fields are processed, matching the all-fields scan in generate_label_schemas()

fiftyone.core.annotation.utils.flatten_fields(collection, fields, require_app_support=False)#

Flattens embedded document fields into dot-separated paths.

Parameters:
  • collection โ€“ the sample collection

  • fields โ€“ iterable of field names to flatten

  • require_app_support (False) โ€“ whether to only include fields supported by the App for annotation

Returns:

sorted list of flattened field names

fiftyone.core.annotation.utils.get_type(field)#

Get the type of a field for a label schema

Parameters:

field โ€“ the field instance

Returns:

a label schema type