# yolov4_parser

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

## Classes

| Name | Description |
| --- | --- |
|
[`YoloV4Parser`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/parsers/yolov4_parser.md)
| Parse a directory with YOLOv4 annotations into LDF. |

### class `YoloV4Parser`

```python
class YoloV4Parser(BaseParser)
```

Parse a directory with YOLOv4 annotations into LDF.

Expected format:

```text
dataset_dir/
├── train/
│   ├── img1.jpg
│   ├── img2.jpg
│   ├── ...
│   ├── _annotations.txt
│   └── _classes.txt
├── valid/
└── test/
```

This is one of the formats that Roboflow can generate.

Methods

| Name | Description |
| --- | --- |
|
[`from_dir`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/parsers/yolov4_parser.md)
| Parse all data in a source dataset directory. |
|
[`from_split`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/parsers/yolov4_parser.md)
| Parse YOLOv4 annotations into LDF records. |
|
[`validate_split`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/parsers/yolov4_parser.md)
| Validate whether a split directory has the expected format. |

#### method `from_dir`

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

Parse all data in a source dataset directory.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `dataset_dir` | `Path` | Source dataset directory. | required |
| `**kwargs` |  | Additional parser-specific arguments. |  |

Returns

| Type | Description |
| --- | --- |
| `tuple[list[Path], list[Path], list[Path]]` | Added images for the train, validation, and test splits. |

#### method `from_split`

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

Parse YOLOv4 annotations into LDF records.

Annotations include classification and object detection.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `image_dir` | `Path` | Directory with images. | required |
| `annotation_path` | `Path` | Annotation file. | required |
| `classes_path` | `Path` | File with class names. | required |

Returns

| Type | Description |
| --- | --- |
| `ParserOutput` | Parser output containing annotation records, skeleton metadata, and added images. |

#### static method `validate_split`

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

Validate whether a split directory has the expected format.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `split_path` | `Path` | Path to a split directory. | required |

Returns

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