# classification_directory_parser

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

## Classes

### ClassificationDirectoryParser

Parse a directory with classification annotations into LDF.

Supports two directory structures:

Split structure with train/valid/test subdirectories:

```text
dataset_dir/
├── train/
│   ├── class1/
│   │   ├── img1.jpg
│   │   ├── img2.jpg
│   │   └── ...
│   ├── class2/
│   └── ...
├── valid/
└── test/
```

Flat structure (class subdirectories directly in root, random splits applied at parse time):

```text
dataset_dir/
├── class1/
│   ├── img1.jpg
│   └── ...
├── class2/
│   └── ...
└── info.json  (optional metadata file)
```

The split structure is one of the formats that Roboflow can generate.

#### Methods

##### 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(class_dir: Path) -> ParserOutput:
```

Parse classification-directory annotations into LDF records.

Annotations include classification labels.

Parameters

 * `class_dir` (`Path`): Top-level class directory.

Returns

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

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