# yolov6_parser

Python API: `luxonis_ml.data.parsers.yolov6_parser`

## Classes

### YoloV6Parser

Parse YOLOv6 annotations into LDF.

Expected format:

```text
dataset_dir/
├── images/
│   ├── train/
│   │   ├── img1.jpg
│   │   ├── img2.jpg
│   │   └── ...
│   ├── valid/
│   └── test/
├── labels/
│   ├── train/
│   │   ├── img1.txt
│   │   ├── img2.txt
│   │   └── ...
│   ├── valid/
│   └── test/
└── data.yaml
```

`data.yaml` contains all class names.

This is one of the formats that Roboflow can generate.

#### Methods

##### discover_dir_splits

```python
def discover_dir_splits(dataset_dir: Path) -> dict[str, dict[str, Any]]:
```

Return present and valid split directories keyed by their canonical split names.

##### from_dir

```python
def from_dir(dataset_dir: Path) -> tuple[list[Path], list[Path], list[Path]]:
```

Parse all data in a source dataset directory.

Parameters

 * `dataset_dir` (`Path`): Source dataset directory.
 * `**kwargs`: Additional parser-specific arguments.

Returns

 * `tuple[list[Path], list[Path], list[Path]]`: Added images for the train, validation, and test splits.

##### from_split

```python
def from_split(image_dir: Path, annotation_dir: Path, classes_path: Path) -> ParserOutput:
```

Parse YOLOv6 annotations into LDF records.

Annotations include classification and object detection.

Parameters

 * `image_dir` (`Path`): Directory with images.
 * `annotation_dir` (`Path`): Directory with annotations.
 * `classes_path` (`Path`): YAML file with class names.

Returns

 * `ParserOutput`: Parser output containing annotation records, skeleton metadata, and added images.

##### validate

```python
def validate(dataset_dir: Path) -> bool:
```

Validate whether the dataset directory has the expected format.

Parameters

 * `dataset_dir` (`Path`): Source dataset directory.

Returns

 * `bool`: Whether the dataset is in the expected format.

##### validate_split

```python
def validate_split(split_path: Path) -> dict[str, Any] | None:
```

Validate whether a split directory has the expected format.

Parameters

 * `split_path` (`Path`): Path to a split directory.

Returns

 * `dict[str, Any] | None`: Keyword arguments for `from_split`, or `None` if the split is not in the expected format.
