# dummy_loader

Python API: `luxonis_train.loaders.dummy_loader`

A loader that yields samples of zeros, for a run without a dataset.

## Classes

| Name | Description |
| --- | --- |
| [`DummyLoader`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/dummy_loader.md#dummy_loader-Classes-DummyLoader) | A loader that yields samples of zeros. |

### class `DummyLoader`

```python
class DummyLoader(BaseLoaderTorch)
```

A loader that yields samples of zeros.

[LuxonisModel](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/core/core.md#core-Classes-LuxonisModel)
uses it in place of the loader of the config when `allow_empty_dataset` is set and that loader fails to build. The samples have
the labels that the tasks of the model nodes require, so the model can build without data.

[get_label_shapes](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/dummy_loader.md#dummy_loader-Classes-DummyLoader-get_label_shapes)
gives a fixed shape to each label type of the Luxonis Data Format. A subclass can override it to give the shapes of other labels.

Properties

| Name | Type | Description |
| --- | --- | --- |
| [`input_shapes`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/dummy_loader.md#dummy_loader-Classes-DummyLoader-input_shapes) | `dict[str, Size]` | The shape `[C, H, W]` of the image, keyed by [image_source](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/base_loader.md#base_loader-Classes-BaseLoaderTorch-image_source). |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/dummy_loader.md#dummy_loader-Classes-DummyLoader-__init__) | Collect the labels of the model and the class names. |
| [`get_classes`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/dummy_loader.md#dummy_loader-Classes-DummyLoader-get_classes) | Return the classes that the constructor built. |
| [`get_label_shapes`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/dummy_loader.md#dummy_loader-Classes-DummyLoader-get_label_shapes) | Return the shape of the zero tensor of each label. |
| [`get_n_keypoints`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/dummy_loader.md#dummy_loader-Classes-DummyLoader-get_n_keypoints) | Return `n_keypoints` for every task. |

#### property `input_shapes`

```python
input_shapes: dict[str, Size]
```

The shape `[C, H, W]` of the image, keyed by
[image_source](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/base_loader.md#base_loader-Classes-BaseLoaderTorch-image_source).

`C` is `1` for the `"GRAY"` color space and `3` for the other color spaces.

#### method `__init__`

```python
def __init__(
    cfg: Config,
    view: list[str],
    height: int | None = None,
    width: int | None = None,
    image_source: str = 'image',
    color_space: Literal['RGB', 'BGR', 'GRAY'] = 'RGB',
    n_keypoints: int = 3,
    n_classes: int = 1,
    class_names: list[str] | dict[str, int] | dict[str, dict[str, int]] | None = None,
    **kwargs,
)
```

Collect the labels of the model and the class names.

The loader does not store augmentations, so the
[augmentation_config](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/base_loader.md#base_loader-Classes-BaseLoaderTorch-augmentation_config)
property raises `ValueError`.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `cfg` | `Config` | The config. The loader reads `trainer.batch_size` and the task of each node in `model.nodes`. Each task gives its required labels, keyed by the `task_name` of the node, or by `""` when the node has no `task_name`. | required |
| `view` | `list[str]` | The splits that form the view. | required |
| `height` | `int | None` | The height of the images and the masks. With `None`, [input_shapes](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/dummy_loader.md#dummy_loader-Classes-DummyLoader-input_shapes) and `__getitem__` raise `ValueError`. | `None` |
| `width` | `int | None` | The width of the images and the masks. With `None`, [input_shapes](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/loaders/dummy_loader.md#dummy_loader-Classes-DummyLoader-input_shapes) and `__getitem__` raise `ValueError`. | `None` |
| `image_source` | `str` | The input name of the image. | `'image'` |
| `color_space` | `Literal['RGB', 'BGR', 'GRAY']` | The color space. The image has one channel for `"GRAY"`, and three channels for the other values. | `'RGB'` |
| `n_keypoints` | `int` | The number of keypoints of each task. | `3` |
| `n_classes` | `int` | The number of classes of each task when `class_names` is `None`. | `1` |
| `class_names` | `list[str] | dict[str, int] | dict[str, dict[str, int]] | None` | The classes. A list gives the class ID from the position of each name. A list or a `dict[str, int]` gives the same classes to every task. A `dict[str, dict[str, int]]` maps each task name to its classes. `None` gives every task the names `"0"` to `str(n_classes - 1)`. | `None` |
| `**kwargs` |  | Other loader parameters of the config. The loader ignores them. |  |

#### method `get_classes`

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

Return the classes that the constructor built.

Returns

| Type | Description |
| --- | --- |
| `dict[str, dict[str, int]]` | The class name to class ID mapping of each task, keyed by the task name. The `class_names` argument of the constructor describes the content. |

#### method `get_label_shapes`

```python
def get_label_shapes(
    labels: dict[str, set[str | Metadata]],
) -> dict[str, tuple[int, ...]]
```

Return the shape of the zero tensor of each label.

The shape of each label type is:

 * `boundingbox`: `[1, 5]`, one box.
 * `keypoints`: `[1, 3 * n_keypoints]`, one instance.
 * `segmentation` and `instance_segmentation`: `[1, height, width]`.
 * Any other label, such as `classification` or a
   [Metadata](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/tasks.md#tasks-Classes-Metadata)
   label: `[2]`.

A subclass can override the method to give other shapes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `labels` | `dict[str, set[str | Metadata]]` | The required labels of each task, keyed by the task name. | required |

Returns

| Type | Description |
| --- | --- |
| `dict[str, tuple[int, ...]]` | The shape of each label, keyed by `"<task_name>/<label>"`. |

#### method `get_n_keypoints`

```python
def get_n_keypoints() -> dict[str, int] | None
```

Return `n_keypoints` for every task.

Every task gets the count, also a task without keypoint labels.

Returns

| Type | Description |
| --- | --- |
| `dict[str, int] | None` | `n_keypoints`, keyed by each task name of the model. |
