@tensorleap_metadata
code_loader.inner_leap_binder.leapbinder_decorators.tensorleap_preprocess.tensorleap_metadata
The tensorleap_metadata decorates a Metadata Function.
@tensorleap_metadata(name='metadata_sample_index', metadata_type={"label": DatasetMetadataType.int, "is_circle": DatasetMetadataType.boolean})
def metadata_sample_index(idx: int, preprocess: PreprocessResponse) -> Union[int, str, bool, float, Dict[str, Union[int, str, bool, float]]]:
passmetadata_type
(DatasetMetadataType, optional) This property helps visualize the metadata data.
For a float metadata value, use
DatasetMetadataType.floatFor a string metadata value, use
DatasetMetadataType.stringFor a int metadata value, use
DatasetMetadataType.intFor a boolean metadata value, use
DatasetMetadataType.booleanFor a dictionary return a dictionary that maps key name to key type
Providing MetadataType becomes mendatory if some of the samples has a "None" value for the metadata
name
(str) The given name of the metadata, e.g. label.
Examples
Basic Usage
from code_loader.contract.datasetclasses import PreprocessResponse
from code_loader.inner_leap_binder.leapbinder_decorators import tensorleap_metadata
import numpy as np
...
@tensorleap_metadata(name='metadata_label_description', metadata_type={"label": DatasetMetadataType.int, "is_circle": DatasetMetadataType.boolean})
def metadata_label(idx: int, preprocess: PreprocessResponse) -> Dict[str, Union[int, bool]]:
return {
'label': int_metadata_creator(preprocess, idx),
'is_circle': bool_metadata_creator(preprocess, idx),
}Usage within the full script can be found at Dataset Script.
Guides
Full examples can be found at the Dataset Integration section of the following guides:
Last updated
Was this helpful?

