Dataset Items

Dataset Items

A dataset version can contain many dataset items. Items are used to access and store the actual items in your dataset version such as images or text. A dataset version can contain many dataset items. Items are used to access and store the actual items in your dataset version such as images or text.

Get dataset items

items = client.get_dataset_items(my_dataset.id, new_dataset_version.id)
ParameterTypeDescription
dataset_idstrThe dataset id
dataset_version_idstrThe dataset version id
paramsdictAdditional query parameter:
Default value: None
Accepted keys:

pageSize: int; Number of items to be returned. Default value: 10.
pageCount: int: The number of the page you want to view.
onlyUnlabelled: bool: If True only return items that are not labelled/annotated.
labelId: str; Only return items that are labelled with this id.
splitId: str; Only return items that are part of this split.

# All params are optional, but here we combine them together for demo purposes. 
params = {
    "onlyUnlabelled": True,
    "pageSize": 25,
    "pageCount": 0,
    "labelId": new_label.id,
    "splitId": my_split.id
}

client.get_dataset_items(my_dataset.id, new_dataset_version.id, params)

Create a dataset item

item = DatasetItem(
    name= "An optional name",
    splits= [my_split]
)

item = client.create_dataset_item(my_dataset.id, new_dataset_version.id, item)
ParameterTypeDescription
dataset_idstrThe dataset id
dataset_version_idstrThe dataset version id
itemDatasetItemThe dataset item object

Dataset item properties in detail:

PropertyTypeDescription
idstrUnique id for the dataset item
created_atstrThe creation date
updated_atstrLast updated date
namestrAn optional name
descriptionstrThe dataset item description
user_idstrThe unique id of the dataset label creator
splitsList[DatasetSplit]The list of dataset splits the dataset item belongs to
annotationsList[Annotation]The list of annotations for the dataset item
extensionstrThe extension for the dataset item.

Get a dataset item

item = client.get_dataset_item(my_dataset["id"], new_dataset_version["id"], item["id"])
ParameterTypeDescription
dataset_idstrThe dataset id
dataset_version_idstrThe dataset version id
item_idstrThe dataset item id

Update a dataset item

item.description = "A better description"

client.update_dataset_item(my_dataset.id, new_dataset_version.id, item)
ParameterTypeDescription
dataset_idstrThe dataset id
dataset_version_idstrThe dataset version id
itemDatasetItemThe dataset item object

Delete a dataset item

client.delete_dataset_item(my_dataset.id, new_dataset_version.id, item.id)
ParameterTypeDescription
dataset_idstrThe dataset id
dataset_version_idstrThe dataset version id
itemstrThe dataset item id

Upload a dataset item image

client.upload_dataset_item_image(my_dataset.id, new_dataset_version.id, item.id, folder="directory/to/item", filename="item_filename.jpg")
ParameterTypeDescription
dataset_idstrThe dataset id
dataset_version_idstrThe dataset version id
itemDatasetItemThe dataset item object

Download a dataset item image

download_location = f"{item.id}.{item.extension}"

client.download_dataset_item_image(my_dataset.id, new_dataset_version.id, item.id, download_location, thumbnail=False)
ParameterTypeDescription
dataset_idstrThe dataset id
dataset_version_idstrThe dataset version id
item_idstrThe dataset item id
download_locationstrThe full location and filename of where to save the item image.
thumbnailboolFlag indicating whether to download the full image or its thumbnail.