fiftyone.utils.lerobot#
LeRobotDataset v3 import and asset resolution utilities.
Exceptions:
The referenced LeRobot source declares an unsupported version. |
|
The requested LeRobot export media mode is unsupported. |
Classes:
|
One episode of a LeRobotDataset v3 source. |
|
One LeRobot source: the id its dataset files it under, where it is and what it declares. |
|
Imports logical episodes from a LeRobotDataset v3 source. |
- exception fiftyone.utils.lerobot.UnsupportedLeRobotVersionError#
Bases:
MediaReferenceErrorThe referenced LeRobot source declares an unsupported version.
Methods:
add_note(object,Β /)Exception.add_note(note) -- add a note to the exception
with_traceback(object,Β /)Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
- add_note(object, /)#
Exception.add_note(note) β add a note to the exception
- args#
- with_traceback(object, /)#
Exception.with_traceback(tb) β set self.__traceback__ to tb and return self.
- exception fiftyone.utils.lerobot.UnsupportedLeRobotExportModeError(export_media, suggestion)#
Bases:
UnsupportedMediaReferenceOperationThe requested LeRobot export media mode is unsupported.
Methods:
add_note(object,Β /)Exception.add_note(note) -- add a note to the exception
with_traceback(object,Β /)Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
- add_note(object, /)#
Exception.add_note(note) β add a note to the exception
- args#
- with_traceback(object, /)#
Exception.with_traceback(tb) β set self.__traceback__ to tb and return self.
- class fiftyone.utils.lerobot.LeRobotEpisodeReference(*args, **kwargs)#
Bases:
MediaReferenceOne episode of a LeRobotDataset v3 source.
The coordinates are the episodeβs own: an episode is a row range of the sourceβs data shard and a time window of each of its camera videos, all of which it shares with the other episodes recorded alongside it.
- Parameters:
key β
<media source id>/<episode index>data β
[chunk index, file index, first row, last row]of the episodeβs rows in the sourceβs tabular datavideos β the episodeβs window in each cameraβs video, keyed by camera, as
[chunk index, file index, from timestamp, to timestamp]tasks β the tasks the episode demonstrates
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 dictionary field that wraps a standard Python dictionary.
A list field that wraps a standard
Field, allowing multiple instances of the field to be stored as a list in the database.The zero-based episode index within the source.
A human-readable name for the referenced media.
An ordered tuple of the public fields of this document.
A unicode string field.
The media type of every reference-backed sample.
The id of the media source on the owning dataset.
Methods:
key_of(source_id,Β episode)The key naming one episode of a source.
episode_of(key)The episode index a reference key names.
of(source_id,Β episode,Β **coordinates)Builds a reference to one episode of a source.
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.
source_of(key)The media source a reference key names.
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:
- data#
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
Fieldinstance 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
- videos#
A dictionary field that wraps a standard Python dictionary.
If this field is not set, its default value is
{}.- Parameters:
field (None) β an optional
Fieldinstance 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
- tasks#
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
Fieldinstance 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
- static key_of(source_id, episode)#
The key naming one episode of a source.
- Parameters:
source_id β the id of the media source on the owning dataset
episode β the zero-based episode index within the source
- Returns:
the key
- static episode_of(key)#
The episode index a reference key names.
- Parameters:
key β a LeRobot episode reference key
- Returns:
the zero-based episode index
- classmethod of(source_id, episode, **coordinates)#
Builds a reference to one episode of a source.
- Parameters:
source_id β the id of the media source on the owning dataset
episode β the zero-based episode index within the source
**coordinates β the episodeβs stored coordinates
- Returns:
- property episode#
The zero-based episode index within the source.
- property display_name#
A human-readable name for the referenced media.
- 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
- key#
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 media_type#
The media type of every reference-backed sample. A sample of one modality names its media by filepath; a reference is what multimodal media is named by.
- merge(doc, merge_lists=True, merge_dicts=True, overwrite=True)#
Merges the contents of the given document into this document.
- Parameters:
doc β a
SerializableDocumentof 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
DocumentMetaclass
- 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_nameis not an allowed field name or does not exist andcreate == False
- property source_id#
The id of the media source on the owning dataset.
- static source_of(key)#
The media source a reference key names.
- Parameters:
key β a media reference key
- Returns:
the source id
- 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
ValidationErrorif any of the fieldsβ values are found to be invalid.
- class fiftyone.utils.lerobot.LeRobotSource(id: str, root: str, info: dict)#
Bases:
objectOne LeRobot source: the id its dataset files it under, where it is and what it declares.
Attributes:
- id: str#
- root: str#
- info: dict#
- class fiftyone.utils.lerobot.LeRobotDatasetImporter(dataset_dir, episodes=None, shuffle=False, seed=None, max_samples=None)#
Bases:
GenericSampleDatasetImporterImports logical episodes from a LeRobotDataset v3 source.
Reads
meta/info.jsonand the episode-metadata shards, nothing else: no data shard, video, or statistics file is opened. Samples are produced one shard at a time, each carrying only its episodeβs key; the dataset records the source once.An episodeβs sample names its media by
media_referencerather thanfilepath, and a reference only resolves through a source the dataset records. Build these datasets from a directory, not by adding samples:import fiftyone as fo import fiftyone.types as fot # one source, one dataset dataset = fo.Dataset.from_dir( dataset_dir="/data/lerobot/pick-place", dataset_type=fot.LeRobotDataset, ) # more sources into the same dataset; each records itself as it # arrives, so every episode stays resolvable dataset.add_dir( dataset_dir="/data/lerobot/sort-nuts", dataset_type=fot.LeRobotDataset, )
add_samplescannot be used to introduce a new source: a sample whose reference names a source the dataset does not record is refused, because nothing would say where its bytes are.- Parameters:
dataset_dir β the LeRobot dataset root, local or remote
episodes (None) β optional episode indexes to import
shuffle (False) β whether to randomly shuffle selected episodes
seed (None) β a random seed to use when shuffling
max_samples (None) β a maximum number of episodes to import
Attributes:
Whether this importer produces a dataset info dictionary.
Whether this importer produces a sample field schema.
Methods:
Returns a dictionary describing the field schema of the samples loaded by this importer.
Returns the dataset info for the dataset.
The media source the importing dataset records before any sample is added, so every sample's reference resolves from the start.
setup()Performs any necessary setup before importing the first sample in the dataset.
close(*args)Performs any necessary actions after the last sample has been imported.
- property has_dataset_info#
Whether this importer produces a dataset info dictionary.
- property has_sample_field_schema#
Whether this importer produces a sample field schema.
- get_sample_field_schema()#
Returns a dictionary describing the field schema of the samples loaded by this importer.
- Returns:
a dict mapping field names to
fiftyone.core.fields.Fieldinstances orstr(field)representations of them
- get_dataset_info()#
Returns the dataset info for the dataset.
By convention, this method should be called after all samples in the dataset have been imported.
- Returns:
a dict of dataset info
- get_media_sources()#
The media source the importing dataset records before any sample is added, so every sampleβs reference resolves from the start.
- setup()#
Performs any necessary setup before importing the first sample in the dataset.
This method is called when the importerβs context manager interface is entered,
DatasetImporter.__enter__().
- close(*args)#
Performs any necessary actions after the last sample has been imported.
This method is called when the importerβs context manager interface is exited,
DatasetImporter.__exit__().- Parameters:
*args β the arguments to
DatasetImporter.__exit__()