module documentation

Validation utilities.

Copyright 2017-2025, Voxel51, Inc.

Function get_field Gets the given sample field and optionally validates its type and value.
Function get_fields Gets the given sample fields and optionally validates their types and values.
Function validate_collection Validates that the provided samples are a fiftyone.core.collections.SampleCollection.
Function validate_collection_label_fields Validates that the fiftyone.core.collections.SampleCollection has fields with the specified fiftyone.core.labels.Label types.
Function validate_image_collection Validates that the provided samples are an image fiftyone.core.collections.SampleCollection.
Function validate_image_sample Validates that the sample's media is an image.
Function validate_non_grouped_collection Validates that the provided samples are a fiftyone.core.collections.SampleCollection that is not grouped.
Function validate_video_collection Validates that the provided samples are a video fiftyone.core.collections.SampleCollection.
Function validate_video_sample Validates that the sample's media is a video.
Variable foc Undocumented
Variable fov Undocumented
Function _validate_fields Undocumented
Function _validate_image Undocumented
def get_field(sample, field_name, allowed_types=None, allow_none=True): (source)

Gets the given sample field and optionally validates its type and value.

Parameters
samplea fiftyone.core.sample.Sample
field_namethe name of the field to get
allowed_types:Nonean optional iterable of fiftyone.core.labels.Label types to enforce that the field value has
allow_none:Truewhether to allow the field to be None
Returns
the field value
Raises
ValueError if the field does not exist or does not meet the specified
criteria
def get_fields(sample, field_names, allowed_types=None, same_type=False, allow_none=True): (source)

Gets the given sample fields and optionally validates their types and values.

Parameters
samplea fiftyone.core.sample.Sample
field_namesan iterable of field names to get
allowed_types:Nonean optional iterable of fiftyone.core.labels.Label types to enforce that the field values have
same_type:Falsewhether to enforce that all fields have same type
allow_none:Truewhether to allow the fields to be None
Returns
a tuple of field values
Raises
ValueError if a field does not exist or does not meet the specified
criteria
def validate_collection(sample_collection, media_type=None): (source)

Validates that the provided samples are a fiftyone.core.collections.SampleCollection.

Parameters
sample_collectiona sample collection
media_type:Nonean optional media type or iterable of media types that the collection must have
Raises
ValueErrorif the provided samples are not a
fiftyone.core.collections.SampleCollection
def validate_collection_label_fields(sample_collection, field_names, allowed_label_types, same_type=False): (source)

Validates that the fiftyone.core.collections.SampleCollection has fields with the specified fiftyone.core.labels.Label types.

Parameters
sample_collectiona fiftyone.core.collections.SampleCollection
field_namesa field name or iterable of field names
allowed_label_typesa fiftyone.core.labels.Label type or iterable of allowed fiftyone.core.labels.Label types
same_type:Falsewhether to enforce that all fields have same type. This condition is enforced separately for sample- and frame-level fields
Raises
ValueError if the required conditions are not met
def validate_image_collection(sample_collection): (source)

Validates that the provided samples are an image fiftyone.core.collections.SampleCollection.

Parameters
sample_collectiona sample collection
Raises
ValueErrorif the provided samples are not an image
fiftyone.core.collections.SampleCollection
def validate_image_sample(sample): (source)

Validates that the sample's media is an image.

Parameters
samplea fiftyone.core.sample.Sample
Raises
ValueError if the sample's media is not an image
def validate_non_grouped_collection(sample_collection): (source)

Validates that the provided samples are a fiftyone.core.collections.SampleCollection that is not grouped.

Parameters
sample_collectiona sample collection
Raises
ValueErrorif the provided samples are a grouped
fiftyone.core.collections.SampleCollection
def validate_video_collection(sample_collection): (source)

Validates that the provided samples are a video fiftyone.core.collections.SampleCollection.

Parameters
sample_collectiona sample collection
Raises
ValueErrorif the provided samples are not a video
fiftyone.core.collections.SampleCollection
def validate_video_sample(sample): (source)

Validates that the sample's media is a video.

Parameters
samplea fiftyone.core.sample.Sample
Raises
ValueError if the sample's media is not a video

Undocumented

Undocumented

def _validate_fields(sample_collection, field_names, allowed_label_types, same_type, frames=False): (source)

Undocumented

def _validate_image(filepath): (source)

Undocumented