fiftyone.core.annotation.utils#
Annotation utils
Functions:
|
Ensure a |
Gets the supported App annotation fields for a |
|
|
Lists all valid annotation fields for a |
|
Populates the |
|
Flattens embedded document fields into dot-separated paths. |
|
Get the |
Lists the label attributes that the given label schemas define but the dataset's field schema has not declared. |
|
Declares on the dataset's field schema the label attributes that the given label schemas define but the dataset has not declared. |
- fiftyone.core.annotation.utils.ensure_collection_is_supported(sample_collection)#
Ensure a
fiftyone.core.collections.SampleCollectionis supported by the App for annotation.- Args:
- sample_collection: a
- 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
imageand3d. Seefiftyone.core.collections.SampleCollection.media_typeAll supported primitive and
embedded.documentprimitives are supported as documented ingenerate_label_schemas()The below
fiftyone.core.labels.Labeltypes are also resolved.- Supported
imagefiftyone.core.labels.Labeltypes are: classification:fiftyone.core.labels.Classificationclassifications:fiftyone.core.labels.Classificationsdetection:fiftyone.core.labels.Detectiondetections:fiftyone.core.labels.Detections
- Supported
3dlabel types are: classification:fiftyone.core.labels.Classificationclassifications:fiftyone.core.labels.Classificationspolyline:fiftyone.core.labels.Polylinepolylines:fiftyone.core.labels.Polylines
- Parameters:
sample_collection β a
fiftyone.core.collections.SampleCollection- Returns:
a list of supported fields
- Supported
- 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.SampleCollectionrequire_app_support (False) β whether to only include fields supported by the App for annotation
flatten (False) β whether to flatten embedded documents with
dot.notationinclude_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
instanceattribute from a legacyindexattribute for any of the given track label fields that haveindexvalues but noinstancevalues yet.Lets datasets whose tracks are defined by
index(rather thaninstance) be recognized as tracks during a scan. Fields that already have anyinstancevalues are left untouched, so existing tracks are never clobbered and the operation is idempotent.- Parameters:
sample_collection β a
fiftyone.core.collections.SampleCollectionfields (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
typeof a field for a label schema- Parameters:
field β the field instance
- Returns:
a label schema
type
- fiftyone.core.annotation.utils.list_undeclared_label_schema_attributes(sample_collection, label_schemas)#
Lists the label attributes that the given label schemas define but the datasetβs field schema has not declared.
Only the datasetβs field schema is read; no samples are scanned.
- Parameters:
sample_collection β a
fiftyone.core.collections.SampleCollectionlabel_schemas β a dict mapping field paths to label schemas
- Returns:
a dict mapping field paths to lists of undeclared attribute names
- fiftyone.core.annotation.utils.declare_label_schema_attributes(sample_collection, label_schemas)#
Declares on the datasetβs field schema the label attributes that the given label schemas define but the dataset has not declared.
A label schema may define attributes that the datasetβs field schema does not know about (
allow_new_attrs), and annotating them stores values without declaring the fields. Everything in the App that reads the field schema, such as the sidebar, its filters and aggregations, then never sees those attributes. Declaring them fixes that.Attributes that already hold values are declared with the type of their values; attributes whose values have mixed types are skipped, with a warning, as
fiftyone.core.dataset.Dataset.add_dynamic_sample_fields()does. Attributes without values are declared with their label schema type.- Parameters:
sample_collection β a
fiftyone.core.collections.SampleCollectionlabel_schemas β a dict mapping field paths to label schemas
- Returns:
the list of paths that were declared