<!-- # hard line break macro for HTML -->

# fiftyone.core.annotation.utils

Annotation utils

Copyright 2017-2026, Voxel51, Inc.
<br/>
[voxel51.com](https://voxel51.com/)
<br/>
<br/>

**Functions:**

| [`ensure_collection_is_supported`](#fiftyone.core.annotation.utils.ensure_collection_is_supported)(sample_collection)   | Ensure a [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection) is supported by the App for annotation.   |
|-------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`get_supported_app_annotation_fields`](#fiftyone.core.annotation.utils.get_supported_app_annotation_fields)(...)       | Gets the supported App annotation fields for a [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection).    |
| [`list_valid_annotation_fields`](#fiftyone.core.annotation.utils.list_valid_annotation_fields)(sample_collection)       | Lists all valid annotation fields for a [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection).           |
| [`backfill_instances_from_index`](#fiftyone.core.annotation.utils.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`](#fiftyone.core.annotation.utils.flatten_fields)(collection, fields[, ...])                           | Flattens embedded document fields into dot-separated paths.                                                                                                                |
| [`get_type`](#fiftyone.core.annotation.utils.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`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection) is
supported by the App for annotation.

> Args:
> : sample_collection: a
>   : [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#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`](fiftyone.core.collections.md#fiftyone.core.collections.SampleCollection).

Currently supported media types for the collection are `image` and
`3d`. See [`fiftyone.core.collections.SampleCollection.media_type`](fiftyone.core.collections.md#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`](fiftyone.core.labels.md#fiftyone.core.labels.Label) types are also resolved.

Supported `image` [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) types are:
: - `classification`:
    [`fiftyone.core.labels.Classification`](fiftyone.core.labels.md#fiftyone.core.labels.Classification)
  - `classifications`:
    [`fiftyone.core.labels.Classifications`](fiftyone.core.labels.md#fiftyone.core.labels.Classifications)
  - `detection`: [`fiftyone.core.labels.Detection`](fiftyone.core.labels.md#fiftyone.core.labels.Detection)
  - `detections`: [`fiftyone.core.labels.Detections`](fiftyone.core.labels.md#fiftyone.core.labels.Detections)

Supported `3d` label types are:
: - `classification`:
    [`fiftyone.core.labels.Classification`](fiftyone.core.labels.md#fiftyone.core.labels.Classification)
  - `classifications`:
    [`fiftyone.core.labels.Classifications`](fiftyone.core.labels.md#fiftyone.core.labels.Classifications)
  - `polyline`: [`fiftyone.core.labels.Polyline`](fiftyone.core.labels.md#fiftyone.core.labels.Polyline)
  - `polylines`: [`fiftyone.core.labels.Polylines`](fiftyone.core.labels.md#fiftyone.core.labels.Polylines)

* **Parameters:**
  **sample_collection** – a
  [`fiftyone.core.collections.SampleCollection`](fiftyone.core.collections.md#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`](fiftyone.core.collections.md#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`](fiftyone.core.collections.md#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`](fiftyone.core.collections.md#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`
