fiftyone.core.validation#
Validation utilities.
Functions:
|
Validates that the sample's media is an image. |
|
Validates that the sample's media is a video. |
|
Validates that the provided samples are a |
|
Validates that the provided samples are an image |
|
Validates that the provided samples are a video |
Validates that the provided samples are a |
|
|
Validates that the |
|
Gets the given sample field and optionally validates its type and value. |
|
Gets the given sample fields and optionally validates their types and values. |
- fiftyone.core.validation.validate_image_sample(sample)#
Validates that the sampleβs media is an image.
- Parameters:
sample β a
fiftyone.core.sample.Sample
- Raises:
ValueError if the sample's media is not an image β
- fiftyone.core.validation.validate_video_sample(sample)#
Validates that the sampleβs media is a video.
- Parameters:
sample β a
fiftyone.core.sample.Sample
- Raises:
ValueError if the sample's media is not a video β
- fiftyone.core.validation.validate_collection(sample_collection, media_type=None)#
Validates that the provided samples are a
fiftyone.core.collections.SampleCollection
.- Parameters:
sample_collection β a sample collection
media_type (None) β an optional media type or iterable of media types that the collection must have
- Raises:
ValueError β if the provided samples are not a
- fiftyone.core.validation.validate_image_collection(sample_collection)#
Validates that the provided samples are an image
fiftyone.core.collections.SampleCollection
.- Parameters:
sample_collection β a sample collection
- Raises:
ValueError β if the provided samples are not an image
- fiftyone.core.validation.validate_video_collection(sample_collection)#
Validates that the provided samples are a video
fiftyone.core.collections.SampleCollection
.- Parameters:
sample_collection β a sample collection
- Raises:
ValueError β if the provided samples are not a video
- fiftyone.core.validation.validate_non_grouped_collection(sample_collection)#
Validates that the provided samples are a
fiftyone.core.collections.SampleCollection
that is not grouped.- Parameters:
sample_collection β a sample collection
- Raises:
ValueError β if the provided samples are a grouped
- fiftyone.core.validation.validate_collection_label_fields(sample_collection, field_names, allowed_label_types, same_type=False)#
Validates that the
fiftyone.core.collections.SampleCollection
has fields with the specifiedfiftyone.core.labels.Label
types.- Parameters:
sample_collection β a
fiftyone.core.collections.SampleCollection
field_names β a field name or iterable of field names
allowed_label_types β a
fiftyone.core.labels.Label
type or iterable of allowedfiftyone.core.labels.Label
typessame_type (False) β whether 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 β
- fiftyone.core.validation.get_field(sample, field_name, allowed_types=None, allow_none=True)#
Gets the given sample field and optionally validates its type and value.
- Parameters:
sample β a
fiftyone.core.sample.Sample
field_name β the name of the field to get
allowed_types (None) β an optional iterable of
fiftyone.core.labels.Label
types to enforce that the field value hasallow_none (True) β whether 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 β
- fiftyone.core.validation.get_fields(sample, field_names, allowed_types=None, same_type=False, allow_none=True)#
Gets the given sample fields and optionally validates their types and values.
- Parameters:
sample β a
fiftyone.core.sample.Sample
field_names β an iterable of field names to get
allowed_types (None) β an optional iterable of
fiftyone.core.labels.Label
types to enforce that the field values havesame_type (False) β whether to enforce that all fields have same type
allow_none (True) β whether 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 β