class Sample(_SampleMixin, Document): (source)
Constructor: Sample(filepath, tags, metadata, **kwargs)
A sample in a fiftyone.core.dataset.Dataset
.
Samples store all information associated with a particular piece of data in a dataset, including basic metadata about the data, one or more sets of labels (ground truth, user-provided, or FiftyOne-generated), and additional features associated with subsets of the data and/or label sets.
Note
Sample
instances that are in datasets are singletons,
i.e., dataset[sample_id] will always return the same
Sample
instance.
Parameters | |
filepath | the path to the data on disk. The path is converted to an
absolute path (if necessary) via
fiftyone.core.storage.normalize_path |
tags | a list of tags for the sample |
metadata | a fiftyone.core.metadata.Metadata instance |
**kwargs | additional fields to dynamically set on the sample |
Class Method | from |
Loads the sample from a JSON dictionary. |
Class Method | from |
Creates a sample backed by the given document. |
Class Method | from |
Creates a sample from the given frame. |
Method | __init__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | reload |
Reloads the sample from the database. |
Method | save |
Saves the sample to the database. |
Method | _reload |
Reloads the backing doc from the database. |
Method | _save |
Undocumented |
Instance Variable | _doc |
Undocumented |
Instance Variable | _frames |
Undocumented |
Inherited from _SampleMixin
:
Method | __getattr__ |
Undocumented |
Method | __getitem__ |
Undocumented |
Method | __iter__ |
Undocumented |
Method | __setattr__ |
Undocumented |
Method | __setitem__ |
Undocumented |
Method | add |
Adds the given labels to the sample. |
Method | clear |
Undocumented |
Method | compute |
Populates the metadata field of the sample. |
Method | copy |
Returns a deep copy of the sample that has not been added to the database. |
Method | get |
Undocumented |
Method | merge |
Merges the fields of the given sample into this sample. |
Method | set |
Undocumented |
Method | to |
Serializes the sample to a JSON dictionary. |
Property | dataset |
Undocumented |
Property | filename |
The basename of the media's filepath. |
Property | media |
The media type of the sample. |
Method | _parse |
Undocumented |
Method | _secure |
Undocumented |
Property | _dataset |
Undocumented |
Inherited from Document
(via _SampleMixin
):
Class Method | from |
Loads the document from a JSON string. |
Method | _reset |
Resets the backing doc for the document. |
Method | _set |
Sets the backing doc for the document. |
Constant | _NO |
Undocumented |
Instance Variable | _dataset |
Undocumented |
Inherited from _Document
(via _SampleMixin
, Document
):
Method | __contains__ |
Undocumented |
Method | __copy__ |
Undocumented |
Method | __delattr__ |
Undocumented |
Method | __delitem__ |
Undocumented |
Method | __dir__ |
Undocumented |
Method | __eq__ |
Undocumented |
Method | __str__ |
Undocumented |
Method | has |
Determines whether the document has the given field. |
Method | iter |
Returns an iterator over the (name, value) pairs of the public fields of the document. |
Method | to |
Serializes the document to a JSON string. |
Method | to |
Serializes the document to a BSON dictionary equivalent to the representation that would be stored in the database. |
Method | update |
Sets the dictionary of fields on the document. |
Property | dataset |
The dataset to which this document belongs, or None if it has not been added to a dataset. |
Property | field |
An ordered tuple of the public field names of this document. |
Property | in |
Whether the document has been added to a dataset. |
Method | _get |
Returns an ordered tuple of field names of this document. |
Method | _iter |
Undocumented |
Method | _parse |
Undocumented |
Property | _collection |
The fiftyone.core.collections.SampleCollection from which this document was taken, or None if it is not in a dataset. |
Property | _id |
The ObjectId of the document, or None if it has not been added to the database. |
Property | _in |
Whether the document has been inserted into the database. |
Loads the sample from a JSON dictionary.
The returned sample will not belong to a dataset.
Returns | |
a Sample |
fiftyone.core.document.Document.from_doc
Creates a sample backed by the given document.
Parameters | |
doc | a fiftyone.core.odm.sample.DatasetSampleDocument or
fiftyone.core.odm.sample.NoDatasetSampleDocument |
dataset:None | the fiftyone.core.dataset.Dataset that
the sample belongs to |
Returns | |
a Sample |
Creates a sample from the given frame.
Parameters | |
frame | a fiftyone.core.frame.Frame |
filepath:None | the path to the corresponding image frame on disk, if not available |
Returns | |
a Sample |
fiftyone.core.document.Document.reload
Reloads the sample from the database.
Parameters | |
hard:False | whether to reload the sample's schema in addition to its field values. This is necessary if new fields may have been added to the dataset schema |