fiftyone.core.labels¶
Labels stored in dataset samples.
Classes:
|
Base class for labels. |
|
Base class for attributes. |
|
A boolean attribute. |
|
A categorical attribute. |
|
A numeric attribute. |
|
A list attribute. |
|
A regression value. |
|
A classification label. |
|
A list of classifications for an image. |
|
An object detection. |
|
A list of object detections in an image. |
|
A set of semantically related polylines or polygons. |
|
A list of polylines or polygons in an image. |
|
A list of keypoints in an image. |
|
A list of |
|
A semantic segmentation for an image. |
|
A heatmap for an image. |
|
A temporal detection in a video whose support is defined by a start and end frame. |
|
A list of temporal detections for a video. |
|
Location data in GeoJSON format. |
|
A batch of location data in GeoJSON format. |
-
class
fiftyone.core.labels.
Label
(*args, **kwargs)¶ Bases:
fiftyone.core.odm.embedded_document.DynamicEmbeddedDocument
Base class for labels.
Label instances represent a logical collection of data associated with a particular task for a sample or frame in a dataset.
Methods:
Returns an iterator over the custom attributes of the label.
has_attribute
(name)Determines whether the label has an attribute with the given name.
get_attribute_value
(name[, default])Gets the value of the attribute with the given name.
set_attribute_value
(name, value)Sets the value of the attribute with the given name.
delete_attribute
(name)Deletes the attribute with the given name.
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()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_json
(s)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.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
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.
Attributes:
An ordered tuple of the public fields of this document.
Classes:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
has_attribute
(name)¶ Determines whether the label has an attribute with the given name.
- Parameters
name – the attribute name
- Returns
True/False
-
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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – if the attribute does not exist and no default value was provided
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
property
field_names
¶ An ordered tuple of the public fields of this 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
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == 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)¶ Bases:
fiftyone.core.odm.embedded_document.DynamicEmbeddedDocument
Base class for attributes.
Attribute instances represent an atomic piece of information, its
value
, usually embedded with aname
within a dict field of anotherLabel
instance.- Parameters
value (None) – the attribute value
Attributes:
A generic field.
An ordered tuple of the public fields of this document.
Methods:
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()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_json
(s)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.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
value
¶ A generic field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
property
field_names
¶ An ordered tuple of the public fields of this 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
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == 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)¶ Bases:
fiftyone.core.labels.Attribute
A boolean attribute.
- Parameters
value (None) – the attribute value
Attributes:
A boolean field.
An ordered tuple of the public fields of this document.
Methods:
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()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_json
(s)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.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
value
¶ A boolean field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
property
field_names
¶ An ordered tuple of the public fields of this 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
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == 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)¶ Bases:
fiftyone.core.labels.Attribute
A categorical attribute.
- Parameters
value (None) – the attribute value
confidence (None) – a confidence in
[0, 1]
for the valuelogits (None) – logits associated with the attribute
Attributes:
A unicode string field.
A floating point number field.
A one-dimensional array field.
An ordered tuple of the public fields of this document.
Methods:
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()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_json
(s)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.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
value
¶ A unicode string field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
confidence
¶ A floating point number field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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 bynumpy.save
and always retrieved as a numpy array.- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
property
field_names
¶ An ordered tuple of the public fields of this 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
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == 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)¶ Bases:
fiftyone.core.labels.Attribute
A numeric attribute.
- Parameters
value (None) – the attribute value
Attributes:
A floating point number field.
An ordered tuple of the public fields of this document.
Methods:
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()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_json
(s)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.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
value
¶ A floating point number field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
property
field_names
¶ An ordered tuple of the public fields of this 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
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == 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)¶ Bases:
fiftyone.core.labels.Attribute
A list attribute.
The list can store arbitrary JSON-serialiable values.
- Parameters
value (None) – the attribute value
Attributes:
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.An ordered tuple of the public fields of this document.
Methods:
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()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_json
(s)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.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
property
field_names
¶ An ordered tuple of the public fields of this 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
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == 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.
Regression
(*args, **kwargs)¶ Bases:
fiftyone.core.labels._HasID
,fiftyone.core.labels.Label
A regression value.
- Parameters
value (None) – the regression value
confidence (None) – a confidence in
[0, 1]
for the regression
Attributes:
A floating point number field.
A floating point number field.
An ordered tuple of the public fields of this document.
An Object ID field.
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.Methods:
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
value
¶ A floating point number field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
confidence
¶ A floating point number field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
id
¶ An Object ID field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == False
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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._HasID
,fiftyone.core.labels.Label
A classification label.
- Parameters
label (None) – the label string
confidence (None) – a confidence in
[0, 1]
for the classificationlogits (None) – logits associated with the labels
Attributes:
A unicode string field.
A floating point number field.
A one-dimensional array field.
An ordered tuple of the public fields of this document.
An Object ID field.
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.Methods:
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
label
¶ A unicode string field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
confidence
¶ A floating point number field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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 bynumpy.save
and always retrieved as a numpy array.- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
id
¶ An Object ID field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == False
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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._HasLabelList
,fiftyone.core.labels.Label
A list of classifications for an image.
- Parameters
classifications (None) – a list of
Classification
instanceslogits (None) – logits associated with the labels
Attributes:
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.A one-dimensional array field.
An ordered tuple of the public fields of this document.
Methods:
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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 bynumpy.save
and always retrieved as a numpy array.- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == 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._HasAttributesDict
,fiftyone.core.labels._HasID
,fiftyone.core.labels.Label
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 detectionindex (None) – an index for the object
attributes ({}) – a dict mapping attribute names to
Attribute
instances
Attributes:
A unicode string field.
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.An n-dimensional array field.
A floating point number field.
A 32 bit integer field.
A dictionary field that wraps a standard Python dictionary.
An ordered tuple of the public fields of this document.
An Object ID field.
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.Methods:
to_polyline
([tolerance, filled])Returns a
Polyline
representation of this instance.to_segmentation
([mask, frame_size, target])Returns a
Segmentation
representation of this instance.to_shapely
([frame_size])Returns a Shapely representation of this instance.
from_mask
(mask[, label])Creates a
Detection
instance with itsmask
attribute populated from the given full image mask.clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
label
¶ A unicode string field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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 bynumpy.save
and always retrieved as a numpy array.- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
confidence
¶ A floating point number field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
index
¶ A 32 bit integer field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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. Typical values are 1-3 pixels
filled (True) – whether the polyline should be filled
- Returns
a
Polyline
-
to_segmentation
(mask=None, frame_size=None, target=255)¶ Returns a
Segmentation
representation of this instance.The detection must have an instance mask, i.e., its
mask
attribute must be populated.You must provide either
mask
orframe_size
to use this method.- Parameters
mask (None) – an optional numpy array to use as an initial mask to which to add this object
frame_size (None) – the
(width, height)
of the segmentation mask to render. This parameter has no effect if amask
is providedtarget (255) – the pixel value or RGB hex string to use to render the object
- Returns
-
to_shapely
(frame_size=None)¶ Returns a Shapely representation of this instance.
- Parameters
frame_size (None) – the
(width, height)
of the image. If provided, the returned geometry will use absolute coordinates- Returns
a
shapely.geometry.polygon.Polygon
-
classmethod
from_mask
(mask, label=None, **attributes)¶ Creates a
Detection
instance with itsmask
attribute populated from the given full image mask.The instance mask for the object is extracted by computing the bounding rectangle of the non-zero values in the image mask.
-
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 dictdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
The specified attribute may either exist in the
attributes
dict or as a dynamic attribute.- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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.
The specified attribute may either exist in the
attributes
dict or as a dynamic attribute.- Parameters
name – the attribute name
default (no_default) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label has an attribute with the given name.
The specified attribute may either exist in the
attributes
dict or as a dynamic attribute.- 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
-
id
¶ An Object ID field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
Attribute may either exist in the
attributes
dict or as dynamic attributes.- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
If the specified attribute already exists in the
attributes
dict, its value is updated there. Otherwise, the attribute is set (or created) as a dynamic attribute.- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == False
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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._HasLabelList
,fiftyone.core.labels.Label
A list of object detections in an image.
- Parameters
detections (None) – a list of
Detection
instances
Attributes:
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.An ordered tuple of the public fields of this document.
Methods:
to_polylines
([tolerance, filled])Returns a
Polylines
representation of this instance.to_segmentation
([mask, frame_size, mask_targets])Returns a
Segmentation
representation of this instance.clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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_segmentation
(mask=None, frame_size=None, mask_targets=None)¶ Returns a
Segmentation
representation of this instance.Only detections with instance masks (i.e., their
mask
attributes populated) will be rendered.You must provide either
mask
orframe_size
to use this method.- Parameters
mask (None) – an optional array to use as an initial mask to which to add objects
frame_size (None) – the
(width, height)
of the segmentation mask to render. This parameter has no effect if amask
is providedmask_targets (None) – a dict mapping integer pixel values (2D masks) or RGB hex strings (3D masks) to label strings defining which object classes to render and which pixel values to use for each class. If omitted, all objects are rendered with pixel value 255
- Returns
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == 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._HasAttributesDict
,fiftyone.core.labels._HasID
,fiftyone.core.labels.Label
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 polylineconfidence (None) – a confidence in
[0, 1]
for the polylineindex (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:
A unicode string field.
A list of lists of
(x, y)
coordinate pairs.A floating point number field.
A 32 bit integer field.
A boolean field.
A boolean field.
A dictionary field that wraps a standard Python dictionary.
An ordered tuple of the public fields of this document.
An Object ID field.
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.Methods:
to_detection
([mask_size, frame_size])Returns a
Detection
representation of this instance whose bounding box tightly encloses the polyline.to_segmentation
([mask, frame_size, target, …])Returns a
Segmentation
representation of this instance.to_shapely
([frame_size, filled])Returns a Shapely representation of this instance.
from_mask
(mask[, label, tolerance])Creates a
Polyline
instance with polygons describing the non-zero region(s) of the given full image mask.from_cuboid
(vertices[, frame_size, label])Constructs a cuboid from its 8 vertices in the format below.
from_rotated_box
(xc, yc, w, h, theta[, …])Constructs a rotated bounding box from its center, dimensions, and rotation.
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
label
¶ A unicode string field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
points
¶ A list of lists of
(x, y)
coordinate pairs.If this field is not set, its default value is
[]
.- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
confidence
¶ A floating point number field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
index
¶ A 32 bit integer field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
closed
¶ A boolean field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
filled
¶ A boolean field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
to_detection
(mask_size=None, frame_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.Alternatively, if a
frame_size
is provided, the required mask size is then computed based off of the polyline points andframe_size
.- Parameters
mask_size (None) – an optional
(width, height)
at which to render an instance mask for the polylineframe_size (None) – used when no
mask_size
is provided. an optional(width, height)
of the frame containing this polyline that is used to compute the requiredmask_size
- Returns
-
to_segmentation
(mask=None, frame_size=None, target=255, thickness=1)¶ Returns a
Segmentation
representation of this instance.You must provide either
mask
orframe_size
to use this method.- Parameters
mask (None) – an optional numpy array to use as an initial mask to which to add objects
frame_size (None) – the
(width, height)
of the segmentation mask to render. This parameter has no effect if amask
is providedtarget (255) – the pixel value or RGB hex string to use to render the object
thickness (1) – the thickness, in pixels, at which to render (non-filled) polylines
- Returns
-
to_shapely
(frame_size=None, filled=None)¶ Returns a Shapely representation of this instance.
The type of geometry returned depends on the number of shapes (
points
) and whether they are polygons or lines (filled
).- Parameters
frame_size (None) – the
(width, height)
of the image. If provided, the returned geometry will use absolute coordinatesfilled (None) – whether to treat the shape as filled (True) or hollow (False) regardless of its
filled
attribute
- Returns
shapely.geometry.polygon.Polygon
: iffilled
is True andpoints
contains a single shapeshapely.geometry.multipolygon.MultiPolygon
: iffilled
is True andpoints
contains multiple shapesshapely.geometry.linestring.LineString
: iffilled
is False andpoints
contains a single shapeshapely.geometry.multilinestring.MultiLineString
: iffilled
is False andpoints
contains multiple shapes
- Return type
one of the following
-
classmethod
from_mask
(mask, label=None, tolerance=2, **attributes)¶ Creates a
Polyline
instance with polygons describing the non-zero region(s) of the given full image mask.
-
classmethod
from_cuboid
(vertices, frame_size=None, label=None, **attributes)¶ Constructs a cuboid from its 8 vertices in the format below:
7--------6 /| /| / | / | 3--------2 | | 4-----|--5 | / | / |/ |/ 0--------1
If a
frame_size
is provided,vertices
must be absolute pixel coordinates; otherwisevertices
should be normalized coordinates in[0, 1] x [0, 1]
.
-
classmethod
from_rotated_box
(xc, yc, w, h, theta, frame_size=None, label=None, **attributes)¶ Constructs a rotated bounding box from its center, dimensions, and rotation.
If a
frame_size
is provided, the provided box coordinates must be absolute pixel coordinates; otherwise they should be normalized coordinates in[0, 1]
. Note that rotations in normalized coordinates only make sense when the source aspect ratio is square.- Parameters
xc – the x-center coordinate
yc – the y-center coorindate
w – the box width
y – the box height
theta – the counter-clockwise rotation of the box in radians
frame_size (None) – the
(width, height)
of the framelabel (None) – the label string
**attributes – additional arguments for the
Polyline
- Returns
a
Polyline
-
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 dictdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
The specified attribute may either exist in the
attributes
dict or as a dynamic attribute.- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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.
The specified attribute may either exist in the
attributes
dict or as a dynamic attribute.- Parameters
name – the attribute name
default (no_default) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label has an attribute with the given name.
The specified attribute may either exist in the
attributes
dict or as a dynamic attribute.- 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
-
id
¶ An Object ID field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
Attribute may either exist in the
attributes
dict or as dynamic attributes.- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
If the specified attribute already exists in the
attributes
dict, its value is updated there. Otherwise, the attribute is set (or created) as a dynamic attribute.- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == False
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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._HasLabelList
,fiftyone.core.labels.Label
A list of polylines or polygons in an image.
- Parameters
polylines (None) – a list of
Polyline
instances
Attributes:
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.An ordered tuple of the public fields of this document.
Methods:
to_detections
([mask_size, frame_size])Returns a
Detections
representation of this instance whose bounding boxes tightly enclose the polylines.to_segmentation
([mask, frame_size, …])Returns a
Segmentation
representation of this instance.clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
to_detections
(mask_size=None, frame_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 eachDetection
.Alternatively, if a
frame_size
is provided, the required mask size is then computed based off of the polyline points andframe_size
.- Parameters
mask_size (None) – an optional
(width, height)
at which to render instance masks for the polylinesframe_size (None) – used when no
mask_size
is provided. an optional(width, height)
of the frame containing these polylines that is used to compute the requiredmask_size
- Returns
-
to_segmentation
(mask=None, frame_size=None, mask_targets=None, thickness=1)¶ Returns a
Segmentation
representation of this instance.You must provide either
mask
orframe_size
to use this method.- Parameters
mask (None) – an optional numpy array to use as an initial mask to which to add objects
frame_size (None) – the
(width, height)
of the segmentation mask to render. This parameter has no effect if amask
is providedmask_targets (None) – a dict mapping integer pixel values (2D masks) or RGB hex strings (3D masks) to label strings defining which object classes to render and which pixel values to use for each class. If omitted, all objects are rendered with pixel value 255
thickness (1) – the thickness, in pixels, at which to render (non-filled) polylines
- Returns
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == 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._HasAttributesDict
,fiftyone.core.labels._HasID
,fiftyone.core.labels.Label
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 list of confidences in
[0, 1]
for each pointindex (None) – an index for the keypoints
attributes ({}) – a dict mapping attribute names to
Attribute
instances
Attributes:
A unicode string field.
A list of
(x, y)
coordinate pairs.A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.A 32 bit integer field.
A dictionary field that wraps a standard Python dictionary.
An ordered tuple of the public fields of this document.
An Object ID field.
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.Methods:
to_shapely
([frame_size])Returns a Shapely representation of this instance.
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
label
¶ A unicode string field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
points
¶ A list of
(x, y)
coordinate pairs.If this field is not set, its default value is
[]
.- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
confidence
¶ 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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
index
¶ A 32 bit integer field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
to_shapely
(frame_size=None)¶ Returns a Shapely representation of this instance.
- Parameters
frame_size (None) – the
(width, height)
of the image. If provided, the returned geometry will use absolute coordinates- Returns
a
shapely.geometry.multipoint.MultiPoint
-
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 dictdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
The specified attribute may either exist in the
attributes
dict or as a dynamic attribute.- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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.
The specified attribute may either exist in the
attributes
dict or as a dynamic attribute.- Parameters
name – the attribute name
default (no_default) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label has an attribute with the given name.
The specified attribute may either exist in the
attributes
dict or as a dynamic attribute.- 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
-
id
¶ An Object ID field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
Attribute may either exist in the
attributes
dict or as dynamic attributes.- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
If the specified attribute already exists in the
attributes
dict, its value is updated there. Otherwise, the attribute is set (or created) as a dynamic attribute.- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == False
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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._HasLabelList
,fiftyone.core.labels.Label
A list of
Keypoint
instances in an image.- Parameters
keypoints (None) – a list of
Keypoint
instances
Attributes:
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.An ordered tuple of the public fields of this document.
Methods:
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == 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._HasID
,fiftyone.core.labels._HasMedia
,fiftyone.core.labels.Label
A semantic segmentation for an image.
Provide either the
mask
ormask_path
argument to define the segmentation.- Parameters
mask (None) – a numpy array with integer values encoding the semantic labels
mask_path (None) – the absolute path to the segmentation image on disk
Attributes:
An n-dimensional array field.
A unicode string field.
Whether this instance has a mask.
An ordered tuple of the public fields of this document.
An Object ID field.
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.Methods:
get_mask
()Returns the segmentation mask for this instance.
import_mask
([update])Imports this instance’s mask from disk to its
mask
attribute.export_mask
(outpath[, update])Exports this instance’s mask to the given path.
transform_mask
(targets_map[, outpath, update])Transforms this instance’s mask according to the provided targets map.
to_detections
([mask_targets, mask_types])Returns a
Detections
representation of this instance with instance masks populated.to_polylines
([mask_targets, mask_types, …])Returns a
Polylines
representation of this instance.clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
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 bynumpy.save
and always retrieved as a numpy array.- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
mask_path
¶ A unicode string field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
property
has_mask
¶ Whether this instance has a mask.
-
get_mask
()¶ Returns the segmentation mask for this instance.
- Returns
a numpy array, or
None
-
import_mask
(update=False)¶ Imports this instance’s mask from disk to its
mask
attribute.- Parameters
outpath – the path to write the map
update (False) – whether to clear this instance’s
mask_path
attribute after importing
-
export_mask
(outpath, update=False)¶ Exports this instance’s mask to the given path.
-
transform_mask
(targets_map, outpath=None, update=False)¶ Transforms this instance’s mask according to the provided targets map.
This method can be used to transform between grayscale and RGB masks, or it can be used to edit the pixel values or colors of a mask without changing the number of channels.
Note that any pixel values not in
targets_map
will be zero in the transformed mask.- Parameters
targets_map – a dict mapping existing pixel values (2D masks) or RGB hex strings (3D masks) to new pixel values or RGB hex strings. You may convert between grayscale and RGB using this argument
outpath (None) – an optional path to write the transformed mask on disk
update (False) – whether to save the transformed mask on this instance
- Returns
the transformed mask
-
to_detections
(mask_targets=None, mask_types='stuff')¶ Returns a
Detections
representation of this instance with instance masks populated.Each
"stuff"
class will be converted to a singleDetection
whose instance mask spans all region(s) of the class.Each
"thing"
class will result in oneDetection
instance per connected region of that class in the segmentation.- Parameters
mask_targets (None) – a dict mapping integer pixel values (2D masks) or RGB hex strings (3D masks) to label strings defining which classes to generate detections for. If omitted, all labels are assigned to their pixel values
mask_types ("stuff") –
whether the classes are
"stuff"
(amorphous regions of pixels) or"thing"
(connected regions, each representing an instance of the thing). Can be any of the following:"stuff"
if all classes are stuff classes"thing"
if all classes are thing classesa dict mapping pixel values (2D masks) or RGB hex strings (3D masks) to
"stuff"
or"thing"
for each class
- Returns
-
to_polylines
(mask_targets=None, mask_types='stuff', tolerance=2)¶ Returns a
Polylines
representation of this instance.Each
"stuff"
class will be converted to a singlePolyline
that may contain multiple disjoint shapes capturing the class.Each
"thing"
class will result in onePolyline
instance per connected region of that class.- Parameters
mask_targets (None) – a dict mapping integer pixel values (2D masks) or RGB hex strings (3D masks) to label strings defining which classes to generate detections for. If omitted, all labels are assigned to their pixel values
mask_types ("stuff") –
whether the classes are
"stuff"
(amorphous regions of pixels) or"thing"
(connected regions, each representing an instance of the thing). Can be any of the following:"stuff"
if all classes are stuff classes"thing"
if all classes are thing classesa dict mapping pixel values (2D masks) or RGB hex strings (3D masks) to
"stuff"
or"thing"
for each class
tolerance (2) – a tolerance, in pixels, when generating approximate polylines for each region. Typical values are 1-3 pixels
- Returns
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
id
¶ An Object ID field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == False
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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.
Heatmap
(*args, **kwargs)¶ Bases:
fiftyone.core.labels._HasID
,fiftyone.core.labels._HasMedia
,fiftyone.core.labels.Label
A heatmap for an image.
Provide either the
map
ormap_path
argument to define the heatmap.- Parameters
map (None) – a 2D numpy array
map_path (None) – the absolute path to the heatmap image on disk
range (None) – an optional
[min, max]
range of the map’s values. If None is provided,[0, 1]
will be assumed ifmap
contains floating point values,[0, 255]
will be assumed ifmap
contains integer values, and the dtype of the image will be assumed ifmap_path
is used
Attributes:
An n-dimensional array field.
A unicode string field.
A
[min, max]
range of the values in afiftyone.core.labels.Heatmap
.Whether this instance has a map.
An ordered tuple of the public fields of this document.
An Object ID field.
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.Methods:
get_map
()Returns the map array for this instance.
import_map
([update])Imports this instance’s map from disk to its
map
attribute.export_map
(outpath[, update])Exports this instance’s map to the given path.
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
map
¶ 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 bynumpy.save
and always retrieved as a numpy array.- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
map_path
¶ A unicode string field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
range
¶ A
[min, max]
range of the values in afiftyone.core.labels.Heatmap
.- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
property
has_map
¶ Whether this instance has a map.
-
get_map
()¶ Returns the map array for this instance.
- Returns
a numpy array, or
None
-
import_map
(update=False)¶ Imports this instance’s map from disk to its
map
attribute.- Parameters
outpath – the path to write the map
update (False) – whether to clear this instance’s
map_path
attribute after importing
-
export_map
(outpath, update=False)¶ Exports this instance’s map to the given path.
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
id
¶ An Object ID field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == False
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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.
TemporalDetection
(*args, **kwargs)¶ Bases:
fiftyone.core.labels._HasID
,fiftyone.core.labels.Label
A temporal detection in a video whose support is defined by a start and end frame.
- Parameters
label (None) – the label string
support (None) – the
[first, last]
frame numbers, inclusiveconfidence (None) – a confidence in
[0, 1]
for the detection
Attributes:
A unicode string field.
A
[first, last]
frame support in a video.A floating point number field.
An ordered tuple of the public fields of this document.
An Object ID field.
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.Methods:
from_timestamps
(timestamps[, sample, metadata])Creates a
TemporalDetection
instance from[start, stop]
timestamps for the specified video.to_timestamps
([sample, metadata])Returns the
[start, stop]
timestamps, in seconds, for this temporal detection in the given video.clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
label
¶ A unicode string field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
support
¶ A
[first, last]
frame support in a video.- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
confidence
¶ A floating point number field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
classmethod
from_timestamps
(timestamps, sample=None, metadata=None, **kwargs)¶ Creates a
TemporalDetection
instance from[start, stop]
timestamps for the specified video.You must provide either
sample
ormetadata
to inform the conversion.- Parameters
timestamps – the
[start, stop]
timestamps, in seconds or “HH:MM:SS.XXX” formatsample (None) – a video
fiftyone.core.sample.Sample
whosemetadata
field is populatedmetadata (None) – a
fiftyone.core.metadata.VideoMetadata
instance**kwargs – additional arguments for
TemporalDetection
- Returns
-
to_timestamps
(sample=None, metadata=None)¶ Returns the
[start, stop]
timestamps, in seconds, for this temporal detection in the given video.You must provide either
sample
ormetadata
to inform the conversion.- Parameters
sample (None) – a video
fiftyone.core.sample.Sample
whosemetadata
field is populatedmetadata (None) – a
fiftyone.core.metadata.VideoMetadata
instance
- Returns
the
[start, stop]
timestamps of this detection, in seconds
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
id
¶ An Object ID field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == False
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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.
TemporalDetections
(*args, **kwargs)¶ Bases:
fiftyone.core.labels._HasLabelList
,fiftyone.core.labels.Label
A list of temporal detections for a video.
- Parameters
detections (None) – a list of
TemporalDetection
instances
Attributes:
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.An ordered tuple of the public fields of this document.
Methods:
clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == 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.
GeoLocation
(*args, **kwargs)¶ Bases:
fiftyone.core.labels._HasID
,fiftyone.core.labels.Label
Location data in GeoJSON format.
- Parameters
point (None) – a
[longitude, latitude]
pointline (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:
A GeoJSON field storing a longitude and latitude coordinate point.
A GeoJSON field storing a line of longitude and latitude coordinates.
A GeoJSON field storing a polygon of longitude and latitude coordinates.
An ordered tuple of the public fields of this document.
An Object ID field.
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.Methods:
Returns a GeoJSON
geometry
dict for this instance.Creates a
GeoLocation
from a GeoJSON dictionary.clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
point
¶ A GeoJSON field storing a longitude and latitude coordinate point.
The data is stored as
[longitude, latitude]
.- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
line
¶ A GeoJSON field storing a line of longitude and latitude coordinates.
The data is stored as follows:
[[lon1, lat1], [lon2, lat2], ...]
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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 (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
id
¶ An Object ID field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == False
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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.
GeoLocations
(*args, **kwargs)¶ Bases:
fiftyone.core.labels._HasID
,fiftyone.core.labels.Label
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:
A GeoJSON field storing a list of points.
A GeoJSON field storing a list of lines.
A GeoJSON field storing a list of polygons.
An ordered tuple of the public fields of this document.
An Object ID field.
A list field that wraps a standard
Field
, allowing multiple instances of the field to be stored as a list in the database.Methods:
Returns a GeoJSON
geometry
dict for this instance.Creates a
GeoLocation
from a GeoJSON dictionary.clean
()Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
delete_attribute
(name)Deletes the attribute with the given name.
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_json
(s)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 label has an attribute with the given name.
has_field
(field_name)Determines whether the document has a field of the given name.
Returns an iterator over the custom attributes of the label.
Returns an iterator over the
(name, value)
pairs of the public fields of the document.merge
(doc[, merge_lists, merge_dicts, overwrite])Merges the contents of the given document into this document.
set_attribute_value
(name, value)Sets the value of the attribute with 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:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
points
¶ A GeoJSON field storing a list of points.
The data is stored as follows:
[[lon1, lat1], [lon2, lat2], ...]
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
lines
¶ A GeoJSON field storing a list of lines.
The data is stored as follows:
[ [[lon1, lat1], [lon2, lat2], ...], [[lon1, lat1], [lon2, lat2], ...], ... ]
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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], ...], ... ], ... ]
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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 (usually validation or assignment) 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
-
delete_attribute
(name)¶ Deletes the attribute with the given name.
- Parameters
name – the attribute name
- Raises
AttributeError – if the attribute does not exist
-
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
-
property
field_names
¶ An ordered tuple of the public fields of this 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) – a default value to return if the attribute does not exist. Can be
None
- Returns
the attribute value
- Raises
AttributeError – 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 label 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
-
id
¶ An Object ID field.
- Parameters
description (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
iter_attributes
()¶ Returns an iterator over the custom attributes of the label.
- Returns
a generator that emits
(name, value)
tuples
-
iter_fields
()¶ Returns an iterator over the
(name, value)
pairs of the public fields of the document.- Returns
an iterator that emits
(name, value)
tuples
-
merge
(doc, merge_lists=True, merge_dicts=True, overwrite=True)¶ Merges the contents of the given document into this document.
- Parameters
doc – a
SerializableDocument
of same type as this documentmerge_lists (True) – whether to merge the elements of top-level list fields rather than treating the list as a single value
merge_dicts (True) – whether to recursively merge the contents of top-level dict fields rather than treating the dict as a single value
overwrite (True) – whether to overwrite (True) or skip (False) existing fields
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
()Return a type’s method resolution order.
-
set_attribute_value
(name, value)¶ Sets the value of the attribute with the given name.
The attribute will be declared if it does not exist.
- Parameters
name – the attribute name
value – the value
-
set_field
(field_name, value, create=True)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (True) – 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 andcreate == False
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 elementsdescription (None) – an optional description
info (None) – an optional info dict
read_only (False) – whether the field is read-only
created_at (None) – the datetime the field was created
-
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.