class documentation

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
filepaththe path to the data on disk. The path is converted to an absolute path (if necessary) via fiftyone.core.storage.normalize_path
tagsa list of tags for the sample
metadataa fiftyone.core.metadata.Metadata instance
**kwargsadditional fields to dynamically set on the sample
Class Method from_dict Loads the sample from a JSON dictionary.
Class Method from_doc Creates a sample backed by the given document.
Class Method from_frame 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_backing_doc 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_labels Adds the given labels to the sample.
Method clear_field Undocumented
Method compute_metadata 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_field Undocumented
Method merge Merges the fields of the given sample into this sample.
Method set_field Undocumented
Method to_dict Serializes the sample to a JSON dictionary.
Property dataset_id Undocumented
Property filename The basename of the media's filepath.
Property media_type The media type of the sample.
Method _parse_fields_video Undocumented
Method _secure_media Undocumented
Property _dataset_id Undocumented

Inherited from Document (via _SampleMixin):

Class Method from_json Loads the document from a JSON string.
Method _reset_backing_doc Resets the backing doc for the document.
Method _set_backing_doc Sets the backing doc for the document.
Constant _NO_DATASET_DOC_CLS 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_field Determines whether the document has the given field.
Method iter_fields Returns an iterator over the (name, value) pairs of the public fields of the document.
Method to_json Serializes the document to a JSON string.
Method to_mongo_dict Serializes the document to a BSON dictionary equivalent to the representation that would be stored in the database.
Method update_fields 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_names An ordered tuple of the public field names of this document.
Property in_dataset Whether the document has been added to a dataset.
Method _get_field_names Returns an ordered tuple of field names of this document.
Method _iter_label_fields Undocumented
Method _parse_fields 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_db Whether the document has been inserted into the database.
@classmethod
def from_dict(cls, d): (source)

Loads the sample from a JSON dictionary.

The returned sample will not belong to a dataset.

Returns
a Sample
@classmethod
def from_doc(cls, doc, dataset=None): (source)

Creates a sample backed by the given document.

Parameters
doca fiftyone.core.odm.sample.DatasetSampleDocument or fiftyone.core.odm.sample.NoDatasetSampleDocument
dataset:Nonethe fiftyone.core.dataset.Dataset that the sample belongs to
Returns
a Sample
@classmethod
def from_frame(cls, frame, filepath=None): (source)

Creates a sample from the given frame.

Parameters
framea fiftyone.core.frame.Frame
filepath:Nonethe path to the corresponding image frame on disk, if not available
Returns
a Sample
def __init__(self, filepath, tags=None, metadata=None, **kwargs): (source)
def __repr__(self): (source)
def reload(self, hard=False): (source)

Reloads the sample from the database.

Parameters
hard:Falsewhether 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
def save(self): (source)

Saves the sample to the database.

def _reload_backing_doc(self): (source)

Reloads the backing doc from the database.

def _save(self, deferred=False): (source)

Undocumented