# fiftyone.core.labels¶

Labels stored in dataset samples.

Classes

 Attribute(*args, **kwargs) Base class for attributes. BooleanAttribute(*args, **kwargs) A boolean attribute. CategoricalAttribute(*args, **kwargs) A categorical attribute. Classification(*args, **kwargs) A classification label. Classifications(*args, **kwargs) A list of classifications (typically from a multilabel model) in an image. Detection(*args, **kwargs) An object detection. Detections(*args, **kwargs) A list of object detections in an image. GeoLocation(*args, **kwargs) Location data in GeoJSON format. GeoLocations(*args, **kwargs) A batch of location data in GeoJSON format. ImageLabel(*args, **kwargs) Base class for labels associated with images. Keypoint(*args, **kwargs) A list of keypoints in an image. Keypoints(*args, **kwargs) A list of Keypoint instances in an image. Label(*args, **kwargs) Base class for labels. ListAttribute(*args, **kwargs) A list attribute. NumericAttribute(*args, **kwargs) A numeric attribute. Polyline(*args, **kwargs) A set of semantically related polylines or polygons. Polylines(*args, **kwargs) A list of polylines or polygons in an image. Segmentation(*args, **kwargs) A semantic segmentation mask for an image.
class fiftyone.core.labels.Label(*args, **kwargs)

Base class for labels.

Label instances represent a logical collection of labels associated with a sample in a dataset. Label instances may represent concrete tasks such as image classification (Classification) or image object detection (Detections), or they may represent higher-level constructs such as a collection of labels for a particular sample (ImageLabels).

Attributes

 STRICT bool(x) -> bool

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.Attribute(*args, **kwargs)

Base class for attributes.

Attribute instances represent an atomic piece of information, its value, usually embedded with a name within a dict field of another Label instance.

Parameters

value (None) – the attribute value

Attributes

 STRICT bool(x) -> bool value Base class for fiftyone.core.sample.Sample fields.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
value

Base class for fiftyone.core.sample.Sample fields.

STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.BooleanAttribute(*args, **kwargs)

A boolean attribute.

Parameters

value (None) – the attribute value

Attributes

 STRICT bool(x) -> bool value A boolean field.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
value

A boolean field.

STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.CategoricalAttribute(*args, **kwargs)

A categorical attribute.

Parameters
• value (None) – the attribute value

• confidence (None) – a confidence in [0, 1] for the value

• logits (None) – logits associated with the attribute

Attributes

 STRICT bool(x) -> bool confidence A floating point number field. logits A one-dimensional array field. value A unicode string field.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
value

A unicode string field.

confidence

A floating point number field.

logits

A one-dimensional array field.

VectorField instances accept numeric lists, tuples, and 1D numpy array values. The underlying data is serialized and stored in the database as zlib-compressed bytes generated by numpy.save and always retrieved as a numpy array.

STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.NumericAttribute(*args, **kwargs)

A numeric attribute.

Parameters

value (None) – the attribute value

Attributes

 STRICT bool(x) -> bool value A floating point number field.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
value

A floating point number field.

STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.ListAttribute(*args, **kwargs)

A list attribute.

The list can store arbitrary JSON-serialiable values.

Parameters

value (None) – the attribute value

Attributes

 STRICT bool(x) -> bool value A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
value

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.ImageLabel(*args, **kwargs)

Base class for labels associated with images.

Attributes

 STRICT bool(x) -> bool

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.Classification(*args, **kwargs)

Bases: fiftyone.core.labels.ImageLabel, fiftyone.core.labels._HasID

A classification label.

Parameters
• label (None) – the label string

• confidence (None) – a confidence in [0, 1] for the classification

• logits (None) – logits associated with the labels

Attributes

 STRICT bool(x) -> bool confidence A floating point number field. id The ID of the label. label A unicode string field. logits A one-dimensional array field. tags A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_attribute(attr) Creates a Classification instance from an attribute. from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
label

A unicode string field.

confidence

A floating point number field.

logits

A one-dimensional array field.

VectorField instances accept numeric lists, tuples, and 1D numpy array values. The underlying data is serialized and stored in the database as zlib-compressed bytes generated by numpy.save and always retrieved as a numpy array.

to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

classmethod from_attribute(attr)

Creates a Classification instance from an attribute.

The attribute value is cast to a string, if necessary.

Parameters

attr – an Attribute or eta.core.data.Attribute

Returns
STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

property id

The ID of the label.

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

tags

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.Classifications(*args, **kwargs)

Bases: fiftyone.core.labels.ImageLabel, fiftyone.core.labels._HasLabelList

A list of classifications (typically from a multilabel model) in an image.

Parameters

classifications (None) – a list of Classification instances

Attributes

 STRICT bool(x) -> bool classifications A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database. logits A one-dimensional array field.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_attributes(attrs[, skip_non_categorical]) Creates a Classifications instance from a list of attributes. from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
classifications

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

logits

A one-dimensional array field.

VectorField instances accept numeric lists, tuples, and 1D numpy array values. The underlying data is serialized and stored in the database as zlib-compressed bytes generated by numpy.save and always retrieved as a numpy array.

to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

classmethod from_attributes(attrs, skip_non_categorical=False)

Creates a Classifications instance from a list of attributes.

Parameters
• attrs – an iterable of Attribute or eta.core.data.Attribute instances

• skip_non_categorical (False) – whether to skip non-categorical attributes (True) or cast all attribute values to strings (False)

Returns
STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.Detection(*args, **kwargs)

Bases: fiftyone.core.labels.ImageLabel, fiftyone.core.labels._HasID, fiftyone.core.labels._HasAttributes

An object detection.

Parameters
• label (None) – the label string

• bounding_box (None) –

a list of relative bounding box coordinates in [0, 1] in the following format:

[<top-left-x>, <top-left-y>, <width>, <height>]


• mask (None) – an instance segmentation mask for the detection within its bounding box, which should be a 2D binary or 0/1 integer NumPy array

• confidence (None) – a confidence in [0, 1] for the detection

• index (None) – an index for the object

• attributes ({}) – a dict mapping attribute names to Attribute instances

Attributes

 STRICT bool(x) -> bool attributes A dictionary field that wraps a standard Python dictionary. bounding_box A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database. confidence A floating point number field. id The ID of the label. index A 32 bit integer field. label A unicode string field. mask An n-dimensional array field. tags A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) Creates a Detection instance from an eta.core.objects.DetectedObject. from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. get_attribute_value(name[, default]) Gets the value of the attribute with the given name. get_field(field_name) Gets the field of the document. Get text score from text query has_attribute(name) Determines whether the detection has an attribute with the given name. has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_detected_object([name]) Returns an eta.core.objects.DetectedObject representation of this instance. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. to_polyline([tolerance, filled]) Returns a Polyline representation of this instance. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
label

A unicode string field.

bounding_box

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

mask

An n-dimensional array field.

ArrayField instances accept numpy array values. The underlying data is serialized and stored in the database as zlib-compressed bytes generated by numpy.save and always retrieved as a numpy array.

confidence

A floating point number field.

index

A 32 bit integer field.

to_polyline(tolerance=2, filled=True)

Returns a Polyline representation of this instance.

If the detection has a mask, the returned polyline will trace the boundary of the mask; otherwise, the polyline will trace the bounding box itself.

Parameters
• tolerance (2) – a tolerance, in pixels, when generating an approximate polyline for the instance mask

• filled (True) – whether the polyline should be filled

Returns
to_detected_object(name=None)

Returns an eta.core.objects.DetectedObject representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.objects.DetectedObject

to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

classmethod from_detected_object(dobj)

Creates a Detection instance from an eta.core.objects.DetectedObject.

Parameters

dobj – a eta.core.objects.DetectedObject

Returns
STRICT = False
attributes

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is {}.

Parameters

field (None) – an optional Field instance describing the type of the values in the dict

clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_attribute_value(name, default=<fiftyone.core.labels._NoDefault object>)

Gets the value of the attribute with the given name.

Parameters
• name – the attribute name

• default (no_default) – the default value to return if the attribute does not exist. Can be None. If no default value is provided, an exception is raised if the attribute does not exist

Returns

the attribute value

Raises

KeyError – if the attribute does not exist and no default value was provided

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_attribute(name)

Determines whether the detection has an attribute with the given name.

Parameters

name – the attribute name

Returns

True/False

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

property id

The ID of the label.

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

tags

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.Detections(*args, **kwargs)

Bases: fiftyone.core.labels.ImageLabel, fiftyone.core.labels._HasLabelList

A list of object detections in an image.

Parameters

detections (None) – a list of Detection instances

Attributes

 STRICT bool(x) -> bool detections A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_detected_objects(objects) Creates a Detections instance from an eta.core.objects.DetectedObjectContainer. from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. to_polylines([tolerance, filled]) Returns a Polylines representation of this instance. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
detections

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

to_polylines(tolerance=2, filled=True)

Returns a Polylines representation of this instance.

For detections with masks, the returned polylines will trace the boundaries of the masks; otherwise, the polylines will trace the bounding boxes themselves.

Parameters
• tolerance (2) – a tolerance, in pixels, when generating approximate polylines for the instance masks

• filled (True) – whether the polylines should be filled

Returns
to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

classmethod from_detected_objects(objects)

Creates a Detections instance from an eta.core.objects.DetectedObjectContainer.

Parameters

objects – a eta.core.objects.DetectedObjectContainer

Returns
STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.Polyline(*args, **kwargs)

Bases: fiftyone.core.labels.ImageLabel, fiftyone.core.labels._HasID, fiftyone.core.labels._HasAttributes

A set of semantically related polylines or polygons.

Parameters
• label (None) – a label for the polyline

• points (None) – a list of lists of (x, y) points in [0, 1] x [0, 1] describing the vertices of each shape in the polyline

• confidence (None) – a confidence in [0, 1] for the polyline

• index (None) – an index for the polyline

• closed (False) – whether the shapes are closed, i.e., and edge should be drawn from the last vertex to the first vertex of each shape

• filled (False) – whether the polyline represents polygons, i.e., shapes that should be filled when rendering them

• attributes ({}) – a dict mapping attribute names to Attribute instances for the polyline

Attributes

 STRICT bool(x) -> bool attributes A dictionary field that wraps a standard Python dictionary. closed A boolean field. confidence A floating point number field. filled A boolean field. id The ID of the label. index A 32 bit integer field. label A unicode string field. points A list of lists of (x, y) coordinate pairs. tags A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. from_eta_polyline(polyline) Creates a Polyline instance from an eta.core.polylines.Polyline. Loads the document from a JSON string. get_attribute_value(name[, default]) Gets the value of the attribute with the given name. get_field(field_name) Gets the field of the document. Get text score from text query has_attribute(name) Determines whether the detection has an attribute with the given name. has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_detection([mask_size]) Returns a Detection representation of this instance whose bounding box tightly encloses the polyline. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_eta_polyline([name]) Returns an eta.core.polylines.Polyline representation of this instance. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
label

A unicode string field.

points

A list of lists of (x, y) coordinate pairs.

If this field is not set, its default value is [].

confidence

A floating point number field.

index

A 32 bit integer field.

closed

A boolean field.

filled

A boolean field.

to_detection(mask_size=None)

Returns a Detection representation of this instance whose bounding box tightly encloses the polyline.

If a mask_size is provided, an instance mask of the specified size encoding the polyline’s shape is included.

Parameters

mask_size (None) – an optional (width, height) at which to render an instance mask for the polyline

Returns
to_eta_polyline(name=None)

Returns an eta.core.polylines.Polyline representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.polylines.Polyline

to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

classmethod from_eta_polyline(polyline)

Creates a Polyline instance from an eta.core.polylines.Polyline.

Parameters

polyline – an eta.core.polylines.Polyline

Returns
STRICT = False
attributes

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is {}.

Parameters

field (None) – an optional Field instance describing the type of the values in the dict

clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_attribute_value(name, default=<fiftyone.core.labels._NoDefault object>)

Gets the value of the attribute with the given name.

Parameters
• name – the attribute name

• default (no_default) – the default value to return if the attribute does not exist. Can be None. If no default value is provided, an exception is raised if the attribute does not exist

Returns

the attribute value

Raises

KeyError – if the attribute does not exist and no default value was provided

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_attribute(name)

Determines whether the detection has an attribute with the given name.

Parameters

name – the attribute name

Returns

True/False

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

property id

The ID of the label.

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

tags

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.Polylines(*args, **kwargs)

Bases: fiftyone.core.labels.ImageLabel, fiftyone.core.labels._HasLabelList

A list of polylines or polygons in an image.

Parameters

polylines (None) – a list of Polyline instances

Attributes

 STRICT bool(x) -> bool polylines A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. from_eta_polylines(polylines) Creates a Polylines instance from an eta.core.polylines.PolylineContainer. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_detections([mask_size]) Returns a Detections representation of this instance whose bounding boxes tightly enclose the polylines. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
polylines

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

to_detections(mask_size=None)

Returns a Detections representation of this instance whose bounding boxes tightly enclose the polylines.

If a mask_size is provided, instance masks of the specified size encoding the polyline’s shape are included in each Detection.

Parameters

mask_size (None) – an optional (width, height) at which to render instance masks for the polylines

Returns
to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

classmethod from_eta_polylines(polylines)

Creates a Polylines instance from an eta.core.polylines.PolylineContainer.

Parameters

polylines – an eta.core.polylines.PolylineContainer

Returns
STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.Keypoint(*args, **kwargs)

Bases: fiftyone.core.labels.ImageLabel, fiftyone.core.labels._HasID, fiftyone.core.labels._HasAttributes

A list of keypoints in an image.

Parameters
• label (None) – a label for the points

• points (None) – a list of (x, y) keypoints in [0, 1] x [0, 1]

• confidence (None) – a confidence in [0, 1] for the points

• index (None) – an index for the keypoints

• attributes ({}) – a dict mapping attribute names to Attribute instances

Attributes

 STRICT bool(x) -> bool attributes A dictionary field that wraps a standard Python dictionary. confidence A floating point number field. id The ID of the label. index A 32 bit integer field. label A unicode string field. points A list of (x, y) coordinate pairs. tags A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. from_eta_keypoints(keypoints) Creates a Keypoint instance from an eta.core.keypoints.Keypoints. Loads the document from a JSON string. get_attribute_value(name[, default]) Gets the value of the attribute with the given name. get_field(field_name) Gets the field of the document. Get text score from text query has_attribute(name) Determines whether the detection has an attribute with the given name. has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_eta_keypoints([name]) Returns an eta.core.keypoints.Keypoints representation of this instance. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
label

A unicode string field.

points

A list of (x, y) coordinate pairs.

If this field is not set, its default value is [].

confidence

A floating point number field.

index

A 32 bit integer field.

to_eta_keypoints(name=None)

Returns an eta.core.keypoints.Keypoints representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.keypoints.Keypoints

to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

classmethod from_eta_keypoints(keypoints)

Creates a Keypoint instance from an eta.core.keypoints.Keypoints.

Parameters

keypoints – an eta.core.keypoints.Keypoints

Returns
STRICT = False
attributes

A dictionary field that wraps a standard Python dictionary.

If this field is not set, its default value is {}.

Parameters

field (None) – an optional Field instance describing the type of the values in the dict

clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_attribute_value(name, default=<fiftyone.core.labels._NoDefault object>)

Gets the value of the attribute with the given name.

Parameters
• name – the attribute name

• default (no_default) – the default value to return if the attribute does not exist. Can be None. If no default value is provided, an exception is raised if the attribute does not exist

Returns

the attribute value

Raises

KeyError – if the attribute does not exist and no default value was provided

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_attribute(name)

Determines whether the detection has an attribute with the given name.

Parameters

name – the attribute name

Returns

True/False

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

property id

The ID of the label.

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

tags

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.Keypoints(*args, **kwargs)

Bases: fiftyone.core.labels.ImageLabel, fiftyone.core.labels._HasLabelList

A list of Keypoint instances in an image.

Parameters

keypoints (None) – a list of Keypoint instances

Attributes

 STRICT bool(x) -> bool keypoints A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. from_eta_keypoints(keypoints) Creates a Keypoints instance from an eta.core.keypoints.KeypointsContainer. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
keypoints

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

classmethod from_eta_keypoints(keypoints)

Creates a Keypoints instance from an eta.core.keypoints.KeypointsContainer.

Parameters

keypoints – an eta.core.keypoints.KeypointsContainer

Returns
STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.Segmentation(*args, **kwargs)

Bases: fiftyone.core.labels.ImageLabel, fiftyone.core.labels._HasID

A semantic segmentation mask for an image.

Parameters

mask (None) – a semantic segmentation mask, which should be a NumPy array with integer values encoding the semantic labels

Attributes

 STRICT bool(x) -> bool id The ID of the label. mask An n-dimensional array field. tags A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Loads the document from a JSON string. from_mask(mask) Creates a Segmentation instance from a mask. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
mask

An n-dimensional array field.

ArrayField instances accept numpy array values. The underlying data is serialized and stored in the database as zlib-compressed bytes generated by numpy.save and always retrieved as a numpy array.

to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

classmethod from_mask(mask)

Creates a Segmentation instance from a mask.

Parameters

Returns
STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

property id

The ID of the label.

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

tags

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.GeoLocation(*args, **kwargs)

Bases: fiftyone.core.labels.ImageLabel, fiftyone.core.labels._HasID

Location data in GeoJSON format.

Parameters
• point (None) – a [longitude, latitude] point

• line (None) –

a line defined by coordinates as shown below:

[[lon1, lat1], [lon2, lat2], ...]


• polygon (None) –

a polygon defined by coorindates as shown below:

[
[[lon1, lat1], [lon2, lat2], ...],
[[lon1, lat1], [lon2, lat2], ...],
...
]


where the first outer list describes the boundary of the polygon and any remaining entries describe holes

Attributes

 STRICT bool(x) -> bool id The ID of the label. line A GeoJSON field storing a line of longitude and latitude coordinates. point A GeoJSON field storing a longitude and latitude coordinate point. polygon A GeoJSON field storing a polygon of longitude and latitude coordinates. tags A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Creates a GeoLocation from a GeoJSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. Returns a GeoJSON geometry dict for this instance. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
point

A GeoJSON field storing a longitude and latitude coordinate point.

The data is stored as [longitude, latitude].

line

A GeoJSON field storing a line of longitude and latitude coordinates.

The data is stored as follow:

[[lon1, lat1], [lon2, lat2], ...]

polygon

A GeoJSON field storing a polygon of longitude and latitude coordinates.

The data is stored as follows:

[
[[lon1, lat1], [lon2, lat2], ...],
[[lon1, lat1], [lon2, lat2], ...],
...
]


where the first element describes the boundary of the polygon and any remaining entries describe holes.

to_geo_json()

Returns a GeoJSON geometry dict for this instance.

Returns

a GeoJSON dict

classmethod from_geo_json(d)

Creates a GeoLocation from a GeoJSON dictionary.

Parameters

d – a GeoJSON dict

Returns
STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

property id

The ID of the label.

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

tags

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.

class fiftyone.core.labels.GeoLocations(*args, **kwargs)

Bases: fiftyone.core.labels.ImageLabel, fiftyone.core.labels._HasID

A batch of location data in GeoJSON format.

The attributes of this class accept lists of data in the format of the corresponding attributes of GeoLocation.

Parameters
• points (None) – a list of points

• lines (None) – a list of lines

• polygons (None) – a list of polygons

Attributes

 STRICT bool(x) -> bool id The ID of the label. lines A GeoJSON field storing a list of lines. points A GeoJSON field storing a list of points. polygons A GeoJSON field storing a list of polygons. tags A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

Methods

 Hook for doing document level data cleaning before validation is run. clear_field(field_name) Clears the field from the document. Returns a deep copy of the document. fancy_repr([class_name, select_fields, …]) Generates a customizable string representation of the document. field_to_mongo(field_name) field_to_python(field_name, value) from_dict(d[, extended]) Loads the document from a BSON/JSON dictionary. Creates a GeoLocation from a GeoJSON dictionary. Loads the document from a JSON string. get_field(field_name) Gets the field of the document. Get text score from text query has_field(field_name) Determines whether the document has a field of the given name. set_field(field_name, value[, create]) Sets the value of a field of the document. to_dict([extended]) Serializes this document to a BSON/JSON dictionary. Returns a GeoJSON geometry dict for this instance. to_image_labels([name]) Returns an eta.core.image.ImageLabels representation of this instance. to_json([pretty_print]) Serializes the document to a JSON string. to_mongo(*args, **kwargs) Return as SON data ready for use with MongoDB. validate([clean]) Ensure that all fields’ values are valid and that required fields are present.

Classes

 my_metaclass Metaclass for all documents.
points

A GeoJSON field storing a list of points.

The data is stored as follows:

[[lon1, lat1], [lon2, lat2], ...]

lines

A GeoJSON field storing a list of lines.

The data is stored as follows:

[
[[lon1, lat1], [lon2, lat2], ...],
[[lon1, lat1], [lon2, lat2], ...],
...
]

polygons

A GeoJSON field storing a list of polygons.

The data is stored as follows:

[
[
[[lon1, lat1], [lon2, lat2], ...],
[[lon1, lat1], [lon2, lat2], ...],
...
],
[
[[lon1, lat1], [lon2, lat2], ...],
[[lon1, lat1], [lon2, lat2], ...],
...
],
...
]

to_geo_json()

Returns a GeoJSON geometry dict for this instance.

Returns

a GeoJSON dict

classmethod from_geo_json(d)

Creates a GeoLocation from a GeoJSON dictionary.

Parameters

d – a GeoJSON dict

Returns
STRICT = False
clean()

Hook for doing document level data cleaning before validation is run.

Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

clear_field(field_name)

Clears the field from the document.

Parameters

field_name – the field name

Raises

ValueError – if the field does not exist

copy()

Returns a deep copy of the document.

Returns

a SerializableDocument

fancy_repr(class_name=None, select_fields=None, exclude_fields=None, **kwargs)

Generates a customizable string representation of the document.

Parameters
• class_name (None) – optional class name to use

• select_fields (None) – iterable of field names to restrict to

• exclude_fields (None) – iterable of field names to exclude

• **kwargs – additional key-value pairs to include in the string representation

Returns

a string representation of the document

field_to_mongo(field_name)
field_to_python(field_name, value)
classmethod from_dict(d, extended=False)

Loads the document from a BSON/JSON dictionary.

Parameters
• d – a dictionary

• extended (False) – whether the input dictionary may contain serialized extended JSON constructs

Returns

a SerializableDocument

classmethod from_json(s)

Loads the document from a JSON string.

Returns

a SerializableDocument

get_field(field_name)

Gets the field of the document.

Parameters

field_name – the field name

Returns

the field value

Raises

AttributeError – if the field does not exist

get_text_score()

Get text score from text query

has_field(field_name)

Determines whether the document has a field of the given name.

Parameters

field_name – the field name

Returns

True/False

property id

The ID of the label.

my_metaclass

alias of mongoengine.base.metaclasses.DocumentMetaclass

set_field(field_name, value, create=False)

Sets the value of a field of the document.

Parameters
• field_name – the field name

• value – the field value

• create (False) – whether to create the field if it does not exist

Raises

ValueError – if field_name is not an allowed field name or does not exist and create == False

tags

A list field that wraps a standard Field, allowing multiple instances of the field to be stored as a list in the database.

If this field is not set, its default value is [].

Parameters

field (None) – an optional Field instance describing the type of the list elements

to_dict(extended=False)

Serializes this document to a BSON/JSON dictionary.

Parameters

extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format

Returns

a dict

to_image_labels(name=None)

Returns an eta.core.image.ImageLabels representation of this instance.

Parameters

name (None) – the name of the label field

Returns

an eta.core.image.ImageLabels

to_json(pretty_print=False)

Serializes the document to a JSON string.

Parameters

pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations

Returns

a JSON string

to_mongo(*args, **kwargs)

Return as SON data ready for use with MongoDB.

validate(clean=True)

Ensure that all fields’ values are valid and that required fields are present.

Raises ValidationError if any of the fields’ values are found to be invalid.