DatasetItems that were imported from a Scale labeling project.
At a high level, the only requirement is a mapping from filepath to metadata fields to update. This filepath should be the same one initially used to upload your data to the Scale labeling project, e.g. s3://path/to/file.jpg. The metadata fields to update should take the form of a Python dict, e.g. {"color": "red", "new_field": "new_value"}.
You can either add new metadata fields or update existing metadata field values.If the field (key in the metadata dict) does not yet exist, the Nucleus API will append the new key-value pair as a queryable metadata field to the item.If the field already exists on the item, the Nucleus API will replace the old value with the newly supplied value.Currently, the Nucleus API does not support deletion of metadata fields.
color which can take on values red, blue, yellow, pink, or green that we want to attach to each image in our Dataset (which was imported from Scale).
- Internally, construct a mapping from each image filepath to the metadata fields you wish to add/update, e.g.:
- Iterate through your
DatasetItemsvia Nucleus API (API Reference). - Retrieve the
image_locationfor eachDatasetItem(orpointcloud_locationfor pointclouds). - Use the mapping from (1) to construct a new Python dict mapping each
DatasetItem.reference_idto its dict of metadata field to update, e.g.:Thereference ID -> new metadatadict mapping should look like this: - Use
Dataset.update_item_metadataand pass in the dict from (4).- To update scene-level metadata of LidarScenes or VideoScenes, use
Dataset.update_scene_metadata.
- To update scene-level metadata of LidarScenes or VideoScenes, use
DatasetItems imported from Scale tasks will have reference_id = task_id (which takes the form of an arbitrary hash, e.g. 61e878916666940043f06d20). Thus you can retrieve the same reference ID (task ID) -> filepath mapping using Scale labeling APIs as well, rather than retrieving it via Nucleus’s DatasetItem export API.
You can then compose this reference ID -> filepath mapping with your filepath -> new metadata mapping to form the desired mapping: reference ID -> new metadata for use with Dataset.update_item_metadata.