# dummy_loader

Python API: `luxonis_train.loaders.dummy_loader`

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

## Classes

### DummyLoader

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)
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)
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.

#### Methods

##### 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)
property raises `ValueError`.

Parameters

 * `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`.
 * `view` (`list[str]`): The splits that form the view.
 * `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)
   and `__getitem__` raise `ValueError`.
 * `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)
   and `__getitem__` raise `ValueError`.
 * `image_source` (`str`): The input name of the image.
 * `color_space` (`Literal['RGB', 'BGR', 'GRAY']`): The color space. The image has one channel for `"GRAY"`, and three channels
   for the other values.
 * `n_keypoints` (`int`): The number of keypoints of each task.
 * `n_classes` (`int`): The number of classes of each task when `class_names` is `None`.
 * `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)`.
 * `**kwargs`: Other loader parameters of the config. The loader ignores them.

##### get_classes

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

Return the classes that the constructor built.

Returns

 * `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.

##### 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)
   label: `[2]`.

A subclass can override the method to give other shapes.

Parameters

 * `labels` (`dict[str, set[str | Metadata]]`): The required labels of each task, keyed by the task name.

Returns

 * `dict[str, tuple[int, ...]]`: The shape of each label, keyed by `"<task_name>/<label>"`.

##### get_n_keypoints

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

Return `n_keypoints` for every task.

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

Returns

 * `dict[str, int] | None`: `n_keypoints`, keyed by each task name of the model.

#### Attributes

##### input_shapes

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).

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