# yolov6_parser

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

## 类

### YoloV6Parser

将 YOLOv6 注释解析为 LDF。

预期格式：

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

`data.yaml` 包含所有类名。

这是 Roboflow 可以生成的一种格式。

#### 方法

##### discover_dir_splits

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

返回按其规范拆分名称键入的现有且有效的拆分目录。

##### from_dir

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

解析源数据集目录中的所有数据。

参数

 * `dataset_dir` (`Path`): 源数据集目录。
 * `**kwargs`: 额外的解析器特定参数。

返回

 * `tuple[list[Path], list[Path], list[Path]]`: 训练、验证和测试拆分中添加的图像。

##### from_split

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

将 YOLOv6 注释解析为 LDF 记录。

注释包括分类和对象检测。

参数

 * `image_dir` (`Path`): 包含图像的目录。
 * `annotation_dir` (`Path`): 包含注释的目录。
 * `classes_path` (`Path`): 包含类名的 YAML 文件。

返回

 * `ParserOutput`: 包含注释记录、骨架元数据和添加图像的解析器输出。

##### validate

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

验证数据集目录是否具有预期格式。

参数

 * `dataset_dir` (`Path`): 源数据集目录。

返回

 * `bool`: 数据集是否为预期格式。

##### validate_split

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

验证拆分目录是否具有预期格式。

参数

 * `split_path` (`Path`): 拆分目录的路径。

返回

 * `dict[str, Any] | None`: `from_split` 的关键字参数，如果拆分不是预期格式，则为 `None`。
