# luxonis_dataset

Python API: `luxonis_ml.data.datasets.luxonis_dataset`

## Classes

| Name | Description |
| --- | --- |
|
[`LuxonisDataset`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Luxonis Dataset Format (LDF) dataset handle. |

### class `LuxonisDataset`

```python
class LuxonisDataset(BaseDataset)
```

Luxonis Dataset Format (LDF) dataset handle.

LDF is a flexible and feature-rich dataset format designed for use within the Luxonis MLOps ecosystem.

Attributes

| Name | Description |
| --- | --- |
| `bucket_storage` | Underlying storage backend for the dataset. |
| `bucket_type` | Whether the dataset uses internal or external buckets. |
| `dataset_name` | Name of the dataset. |
| `team_id` | Optional cloud team identifier. |

Properties

| Name | Type | Description |
| --- | --- | --- |
|
[`identifier`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| `str` | The unique identifier for the dataset. |
|
[`is_remote`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| `bool` | Whether the dataset is stored remotely (in a cloud bucket) or locally. |
|
[`metadata`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| `Metadata` | Get the dataset metadata. |
|
[`source`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| `LuxonisSource` | Get the source information for the dataset. |
|
[`version`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| `Version` | The version of the underlying LDF that the dataset adheres to. |

Methods

| Name | Description |
| --- | --- |
|
[`__init__`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Create a Luxonis Dataset Format dataset handle. |
|
[`add`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Add data to the dataset from a generator of records. |
|
[`clone`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Create a local copy of the current dataset. |
|
[`delete_dataset`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Delete the dataset from local storage and optionally the cloud. |
|
[`exists`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Check whether a dataset exists. |
|
[`export`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Export the dataset into one of the supported formats. |
|
[`get_categorical_encodings`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Get the categorical encodings for the dataset grouped by task. |
|
[`get_classes`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Get class names and IDs per task. |
|
[`get_metadata_types`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Get the metadata types for each metadata annotation in the dataset. |
|
[`get_skeletons`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Return keypoint skeletons for each task. |
|
[`get_source_names`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Return input source names for the dataset. |
|
[`get_splits`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Get the dataset splits definitions. |
|
[`get_statistics`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Return dataset statistics for a view or the full dataset. |
|
[`get_tasks`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Return task names and task types. |
|
[`list_datasets`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| List available datasets. |
|
[`make_splits`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Create dataset splits for training, validation, and testing. |
|
[`merge_with`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Merge another dataset into this or a new dataset. |
|
[`pull_from_cloud`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Synchronize the dataset from a remote bucket to a local storage. |
|
[`push_to_cloud`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Push the local dataset to a remote bucket. |
|
[`remove_duplicates`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Remove duplicate files and annotations from the dataset. |
|
[`set_class_order_per_task`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Set class order for specific tasks. |
|
[`set_classes`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Set classes for one or more tasks. |
|
[`set_skeletons`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Set keypoint skeleton metadata. |
|
[`set_tasks`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Set dataset tasks. |
|
[`update_source`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/datasets/luxonis_dataset.md)
| Update the dataset source definition. |

#### property `identifier`

```python
identifier: str
```

The unique identifier for the dataset.

#### property `is_remote`

```python
is_remote: bool
```

Whether the dataset is stored remotely (in a cloud bucket) or locally.

#### property `metadata`

```python
metadata: Metadata
```

Get the dataset metadata.

Returns

| Type | Description |
| --- | --- |
|  | Deep copy of the dataset metadata. |

#### property `source`

```python
source: LuxonisSource
```

Get the source information for the dataset.

Returns

| Type | Description |
| --- | --- |
|  | Dataset source metadata. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If source metadata is missing. |

#### property `version`

```python
version: Version
```

The version of the underlying LDF that the dataset adheres to.

#### method `__init__`

```python
def __init__(
    dataset_name: str,
    team_id: str | None = None,
    bucket_type: BucketType | Literal['internal', 'external'] = BucketType.INTERNAL,
    bucket_storage: BucketStorage | Literal['local', 'gcs', 's3', 'azure'] = BucketStorage.LOCAL,
    *,
    delete_local: bool = False,
    delete_remote: bool = False,
)
```

Create a Luxonis Dataset Format dataset handle.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `dataset_name` | `str` | Dataset name. | required |
| `team_id` | `str | None` | Optional cloud team identifier. | `None` |
| `bucket_type` | `BucketType | Literal['internal', 'external']` | Whether the dataset uses internal or external buckets. |
`BucketType.INTERNAL` |
| `bucket_storage` | `BucketStorage | Literal['local', 'gcs', 's3', 'azure']` | Underlying storage backend. |
`BucketStorage.LOCAL` |
| `delete_local` | `bool` | Whether to delete a local dataset with the same name before initialization. | `False` |
| `delete_remote` | `bool` | Whether to delete the remote dataset as well. | `False` |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the dataset exists and deletion flags are not set. |
| `ValueError` | If the dataset is remote but no bucket is configured. |
| `NotImplementedError` | If Azure Blob Storage is selected as the bucket storage. |

#### method `add`

```python
def add(generator: DatasetIterator, batch_size: int = 1000000) -> Self
```

Add data to the dataset from a generator of records.

Args

 * `generator` (`DatasetIterator`): The generator should yield either dictionaries that can be converted to `DatasetRecord`
   objects or actual `DatasetRecord` instances. Each record must contain at least a file path and can optionally include an
   annotation and a task name. Use `sample_metadata` for values attached to the whole sample rather than to one annotation. For
   example:```python
   def record_generator():
       yield {
           "file": "/path/to/image.jpg",
           "task_name": "animals",
           "sample_metadata": {
               "record_id": 123,
               "camera": "left",
               "tags": ["night", "warehouse"],
           },
           "annotation": {
               "instance_id": 1,
               "class": "cat",
               "boundingbox": {
                   "x": 0.10,
                   "y": 0.20,
                   "w": 0.30,
                   "h": 0.40,
               },
               "keypoints": {
                   "keypoints": [
                       (0.15, 0.25, 1),
                       (0.50, 0.60, 1),
                       (0.70, 0.80, 0),
                   ],
               },
               "instance_segmentation": {
                   "mask": "/path/to/mask.png",
               },
           },
       }
   ```
   [LuxonisLoader](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/loaders/luxonis_loader.md) returns `sample_metadata` through [LoaderOutput.metadata](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/typing.md). Annotation metadata under `annotation["metadata"]` is different: it becomes a metadata label task.
 * `batch_size` (`int`): The number of records to process in a batch before writing to storage. Larger batch sizes may be more efficient but will use more memory.

Returns

| Type | Description |
| --- | --- |
| `Self` |  |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the records yielded by the generator are not in the expected format. |
| `ValueError` | If the dataset contains metadata annotations with conflicting types. |

#### method `clone`

```python
def clone(
    new_dataset_name: str,
    push_to_cloud: bool = True,
    splits_to_clone: list[str] | None = None,
    team_id: str | None = None,
) -> LuxonisDataset
```

Create a local copy of the current dataset.

> **Warning**
> The cloned dataset overwrites any existing dataset with the same name.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `new_dataset_name` | `str` | Name of the cloned dataset. | required |
| `push_to_cloud` | `bool` | Whether to push the cloned dataset to the cloud when the current dataset is remote. | `True` |
| `splits_to_clone` | `list[str] | None` | Optional split names to clone. If omitted, all data is cloned. | `None` |
| `team_id` | `str | None` | Optional team identifier for the cloned dataset. | `None` |

Returns

| Type | Description |
| --- | --- |
| `LuxonisDataset` | Cloned dataset handle. |

Raises

| Type | Description |
| --- | --- |
| `FileNotFoundError` | If the current dataset is empty and `splits_to_clone` is specified. |

#### method `delete_dataset`

```python
def delete_dataset(*, delete_remote: bool = False, delete_local: bool = False)
```

Delete the dataset from local storage and optionally the cloud.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `delete_remote` | `bool` | Whether to delete the remote dataset. | `False` |
| `delete_local` | `bool` | Whether to delete the local dataset files. | `False` |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If neither `delete_remote` nor `delete_local` is set to `True`. |

#### static method `exists`

```python
def exists(
    dataset_name: str,
    team_id: str | None = None,
    bucket_storage: BucketStorage = BucketStorage.LOCAL,
    bucket: str | None = None,
) -> bool
```

Check whether a dataset exists.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `dataset_name` | `str` | Dataset name to check. | required |
| `team_id` | `str | None` | Optional team identifier. | `None` |
| `bucket_storage` | `BucketStorage` | Storage backend to inspect. | `BucketStorage.LOCAL` |
| `bucket` | `str | None` | Optional bucket name for remote storage. | `None` |

Returns

| Type | Description |
| --- | --- |
| `bool` | `True` if the dataset exists, `False` otherwise. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If bucket storage is remote but no bucket name is provided. |

#### method `export`

```python
def export(
    output_path: PathType,
    dataset_type: DatasetType = DatasetType.NATIVE,
    max_partition_size_gb: float | None = None,
    zip_output: bool = False,
    ldf_version: str | None = None,
) -> Path | list[Path]
```

Export the dataset into one of the supported formats.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output_path` | `PathType` | Directory where the dataset should be exported. | required |
| `dataset_type` | `DatasetType` | Export format. | `DatasetType.NATIVE` |
| `max_partition_size_gb` | `float | None` | Optional maximum partition size. If the dataset exceeds this size, it is split into partitions named `{dataset_name}_part{partition_number}`. | `None` |
| `zip_output` | `bool` | Whether to zip the exported dataset or each partition after export. | `False` |
| `ldf_version` | `str | None` | LDF version to write, for example `"2.0"`, so the export can be read by an older luxonis-ml. Native format only. Defaults to the version this installation writes. Downgrading is lossy and warns about what it drops. | `None` |

Returns

| Type | Description |
| --- | --- |
| `Path | list[Path]` | Export directory, or ZIP archive paths when `zip_output` is enabled. |

Raises

| Type | Description |
| --- | --- |
| `NotImplementedError` | If the specified export format is not supported. |
| `ValueError` | If the output path already exists, or if `ldf_version` is set for a non-native format or names a version this installation cannot write. |

#### method `get_categorical_encodings`

```python
def get_categorical_encodings() -> dict[str, dict[str, int]]
```

Get the categorical encodings for the dataset grouped by task.

Example output:

```python
{
    "vehicles": {
        "color": {"red": 0, "green": 1, "blue": 2},
        "brand": {"audi": 0, "bmw": 1, "mercedes": 2},
    }
}
```

#### method `get_classes`

```python
def get_classes() -> dict[str, dict[str, int]]
```

Get class names and IDs per task.

Returns

 * `Mapping from class names to class IDs grouped by task name`:```pycon
   {
       "color": {"red": 0, "green": 1, "blue": 2},
       "brand": {"audi": 0, "bmw": 1, "mercedes": 2},
   }
   ```

#### method `get_metadata_types`

```python
def get_metadata_types() -> dict[str, Literal['float', 'int', 'str', 'Category']]
```

Get the metadata types for each metadata annotation in the dataset.

Example output:

```python
{
    "id": "int",
    "time_of_day": "Category",
    "temperature": "float",
}
```

#### method `get_skeletons`

```python
def get_skeletons() -> dict[str, tuple[list[str], list[tuple[int, int]]]]
```

Return keypoint skeletons for each task.

Returns

| Type | Description |
| --- | --- |
| `dict[str, tuple[list[str], list[tuple[int, int]]]]` | Keypoint labels and edges keyed by task name. |

#### method `get_source_names`

```python
def get_source_names() -> list[str]
```

Return input source names for the dataset.

Returns

| Type | Description |
| --- | --- |
| `list[str]` | Source names used to identify input data. |

#### method `get_splits`

```python
def get_splits() -> dict[str, list[str]] | None
```

Get the dataset splits definitions.

Returns

| Type | Description |
| --- | --- |
| `dict[str, list[str]] | None` | A mapping of split names to list of UUIDs, or `None` if no splits are defined. |

#### method `get_statistics`

```python
def get_statistics(
    sample_size: int | None = None,
    view: str | None = None,
) -> dict[str, Any]
```

Return dataset statistics for a view or the full dataset.

The returned statistics include:

 * `"duplicates"`: Analysis of duplicated content.
 * `"class_distributions"`: Class frequencies organized by task name and task type. Classification tasks are excluded.
 * `"missing_annotations"`: File paths that lack annotations.
 * `"heatmaps"`: Spatial annotation distributions.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `sample_size` | `int | None` | Optional number of samples used for heatmap generation. | `None` |
| `view` | `str | None` | Optional split name to analyze. If omitted, the entire dataset is analyzed. | `None` |

Returns

| Type | Description |
| --- | --- |
| `dict[str, Any]` | Dataset statistics. |

#### method `get_tasks`

```python
def get_tasks() -> dict[str, list[str]]
```

Return task names and task types.

Returns

| Type | Description |
| --- | --- |
| `dict[str, list[str]]` | Task types keyed by task name. |

#### static method `list_datasets`

```python
def list_datasets(
    team_id: str | None = None,
    bucket_storage: BucketStorage = BucketStorage.LOCAL,
    bucket: str | None = None,
) -> list[str]
```

List available datasets.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `team_id` | `str | None` | Optional team identifier. | `None` |
| `bucket_storage` | `BucketStorage` | Storage backend to inspect. | `BucketStorage.LOCAL` |
| `bucket` | `str | None` | Optional bucket name for remote storage. | `None` |

Returns

| Type | Description |
| --- | --- |
| `list[str]` | List of dataset names. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If bucket storage is remote but no bucket name is provided. |
| `ValueError` | If the dataset is stored remotely but no `bucket` parameter is provided or no `LUXONISML_BUCKET` environment
variable is set. |

#### method `make_splits`

```python
def make_splits(
    splits: Mapping[str, Sequence[PathType]] | Mapping[str, float] | tuple[float, float, float] | None = None,
    *,
    replace_old_splits: bool = False,
)
```

Create dataset splits for training, validation, and testing.

> **Note**
> Although `"train"`, `"val"`, and `"test"` are the conventional split names, you can use any split names you want by providing a mapping to the `splits` argument. This can be useful for combining records from multiple sources (`"train_real"`, `"train_synth"`) or for creating fully custom splits.

Args

 * `splits` (`Mapping[str, Sequence[PathType]] | Mapping[str, float] | tuple[float, float, float] | None`): A mapping defining the
   splits. Can be one of the following: * A mapping of split names to lists of file paths.
    * A mapping of split names to ratios.
    * A tuple of three ratios for train, val, and test splits. A ratio is a number from 0 to 1, and the ratios sum to 1. `1` and
      `1.0` both work.
 * `replace_old_splits` (`bool`): Whether to replace old splits with new ones. If `False` (default), new splits are added to the
   existing splits. If `True`, the existing splits are discarded first.

Raises

| Type | Description |
| --- | --- |
| `TypeError` | If the mapping values are neither ratios nor filepath lists. The method warns and skips each element of a filepath
list that is not a filepath. |
| `ValueError` | If `splits` is provided but is empty. |
| `ValueError` | If the ratios are outside the range from 0 to 1 or do not sum to 1. |
| `ValueError` | If split ratios are used but all the data already belongs to a split while `replace_old_splits` is `False`. |
| `FileNotFoundError` | If the dataset is empty. |

#### method `merge_with`

```python
def merge_with(
    other: LuxonisDataset,
    inplace: bool = True,
    new_dataset_name: str | None = None,
    splits_to_merge: list[str] | None = None,
    team_id: str | None = None,
) -> LuxonisDataset
```

Merge another dataset into this or a new dataset.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `other` | `LuxonisDataset` | Dataset to merge into this dataset. | required |
| `inplace` | `bool` | Whether to merge into this dataset. If `False`, a new dataset is created. | `True` |
| `new_dataset_name` | `str | None` | Name of the new dataset when `inplace` is `False`. | `None` |
| `splits_to_merge` | `list[str] | None` | Optional split names to merge. | `None` |
| `team_id` | `str | None` | Optional team identifier for a newly created dataset. | `None` |

Returns

| Type | Description |
| --- | --- |
| `LuxonisDataset` | Dataset containing the merged data. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the datasets have different bucket storage types. |
| `ValueError` | If `inplace` is `False` but no name for the new dataset is provided. |

#### method `pull_from_cloud`

```python
def pull_from_cloud(update_mode: UpdateMode = UpdateMode.MISSING)
```

Synchronize the dataset from a remote bucket to a local storage.

Annotations and metadata are always pulled. Media files are pulled either when missing locally or always, depending on
`update_mode`.

The pull overwrites the local `annotations/` and `metadata/` folders with the remote copies on every call, so local-only edits to
those folders are lost.

With `UpdateMode.MISSING`, a media file counts as missing only when both locations are absent:

 * the path in the `file` column of the Parquet shard;
 * `media/<uuid><suffix>`, where the UUID comes from the `uuid` column of the same shard.

With `UpdateMode.ALL`, every media file is downloaded again and overwrites the local copy.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `update_mode` | `UpdateMode` | Media synchronization mode. | `UpdateMode.MISSING` |

#### method `push_to_cloud`

```python
def push_to_cloud(
    bucket_storage: BucketStorage | None,
    update_mode: UpdateMode = UpdateMode.MISSING,
)
```

Push the local dataset to a remote bucket.

Annotations and metadata are always pushed. Media files are pushed either when missing remotely or always, depending on
`update_mode`.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `bucket_storage` | `BucketStorage | None` | Remote storage backend to push to. If unset, uses the dataset's current bucket
storage type. | required |
| `update_mode` | `UpdateMode` | Media synchronization mode. | `UpdateMode.MISSING` |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the dataset is empty or not initialized. |
| `FileNotFoundError` | If any media files are missing locally when attempting to push. |

#### method `remove_duplicates`

```python
def remove_duplicates()
```

Remove duplicate files and annotations from the dataset.

Raises

| Type | Description |
| --- | --- |
| `FileNotFoundError` | If the dataset is empty. |

#### method `set_class_order_per_task`

```python
def set_class_order_per_task(class_order_per_task: dict[str, list[str]])
```

Set class order for specific tasks.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `class_order_per_task` | `dict[str, list[str]]` | Mapping from task names to class names in the desired order. | required |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If a task is missing or the provided class names do not match the dataset classes for that task. |

#### method `set_classes`

```python
def set_classes(
    classes: list[str] | dict[str, int],
    task: str | None = None,
    rewrite_metadata: bool = True,
)
```

Set classes for one or more tasks.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `classes` | `list[str] | dict[str, int]` | Class names, or class IDs keyed by class name. If class names are provided, IDs are
assigned alphabetically starting from 0. A class named `"background"` is always assigned ID 0. | required |
| `task` | `str | None` | Optional task to update. If omitted, all tasks are updated. | `None` |
| `rewrite_metadata` | `bool` |  | `True` |

#### method `set_skeletons`

```python
def set_skeletons(
    labels: list[str] | None = None,
    edges: list[tuple[int, int]] | None = None,
    task: str | None = None,
)
```

Set keypoint skeleton metadata.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `labels` | `list[str] | None` | Optional keypoint names. | `None` |
| `edges` | `list[tuple[int, int]] | None` | Optional keypoint edges as 0-based index pairs. | `None` |
| `task` | `str | None` | Optional task to update. If omitted, all tasks are updated. | `None` |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If neither `labels` nor `edges` is provided. |

#### method `set_tasks`

```python
def set_tasks(tasks: Mapping[str, Iterable[str]])
```

Set dataset tasks.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `tasks` | `Mapping[str, Iterable[str]]` | Mapping from task names to task types. | required |

#### method `update_source`

```python
def update_source(source: LuxonisSource)
```

Update the dataset source definition.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `source` | `LuxonisSource` | Source definition to store. | required |
