class documentation

Parse YOLOv8 and Ultralytics annotations into LDF.

Expected format:

dataset_dir/
├── images/
│   ├── train/
│   │   ├── img1.jpg
│   │   ├── img2.jpg
│   │   └── ...
│   ├── val/
│   └── test/
├── labels/
│   ├── train/
│   │   ├── img1.txt
│   │   ├── img2.txt
│   │   └── ...
│   ├── val/
│   └── test/
└── *.yaml

OR::

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

*.yaml contains all class names.

This is one of the formats that Roboflow can generate.

Class Method discover_dir_splits Return present and valid split directories keyed by their canonical split names.
Class Method validate Validate whether the dataset directory has the expected format.
Static Method validate_split Validate whether a split directory has the expected format.
Method fit_boundingbox Fit a bounding box around a polygon mask.
Method from_dir Parse all YOLOv8 splits in a source dataset directory.
Method from_split Parse YOLOv8 or Ultralytics annotations into LDF records.
Static Method _detect_dataset_dir_format Detect whether a dataset uses Ultralytics or Roboflow layout.

Inherited from BaseParser:

Method __init__ Create a parser for a target dataset.
Method get_parser_issue_messages Return parser issue messages collected during the last parse.
Method parse_dir Parse an entire dataset directory into the target dataset.
Method parse_split Parse one split subdirectory into the target dataset.
Method reset_parser_issue_messages Clear collected parser issue messages.
Static Method _apply_counts_to_pool Distribute images across splits based on requested counts.
Static Method _apply_counts_to_splits Apply count-based split requests to existing splits.
Static Method _canonicalize_split_name All current parsers use train and test split names whereas validation splits can vary in name between val valid and validation.
Static Method _compare_stem_files Compare sets of files by stem.
Static Method _get_added_images Return unique images yielded by a dataset generator.
Static Method _list_images List OpenCV-supported images in a directory.
Static Method _sample_from_splits Sample from each original split independently.
Method _get_parser_issue_messages Return parser issue messages collected during the last parse.
Method _log_skipped_annotation_summary Undocumented
Method _parse_available_splits Undocumented
Method _parse_split Parse data in one split subdirectory.
Method _remove_unsplit_records Remove records that are not assigned to any split.
Method _reset_parser_issue_messages Clear collected parser issue messages and warning counters.
Method _warn_skipped_annotation Undocumented
Method _wrap_generator Add configured task names to generated records.
Constant _CANONICAL_SPLIT_NAMES Undocumented
Constant _SKIPPED_WARNING_LIMIT Undocumented
Constant _SPLIT_NAMES Undocumented
Instance Variable _dataset Undocumented
Instance Variable _dataset_type Undocumented
Instance Variable _full_warnings Undocumented
Instance Variable _logged_skipped_annotation_warnings Undocumented
Instance Variable _parser_issue_messages Undocumented
Instance Variable _seen_parser_issue_messages Undocumented
Instance Variable _skipped_annotation_counts_by_reason Undocumented
Instance Variable _suppressed_skipped_annotation_warnings Undocumented
Instance Variable _task_name Undocumented
@classmethod
@override
def discover_dir_splits(cls, dataset_dir: Path) -> dict[str, dict[str, Any]]:

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

@classmethod
def validate(cls, dataset_dir: Path) -> bool:

Validate whether the dataset directory has the expected format.

Parameters
dataset_dir:PathSource dataset directory.
Returns
boolWhether the dataset is in the expected format.
@staticmethod
def validate_split(split_path: Path) -> dict[str, Any] | None:

Validate whether a split directory has the expected format.

Parameters
split_path:PathPath to a split directory.
Returns
dict[str, Any] | NoneKeyword arguments for from_split, or None if the split is not in the expected format.
def fit_boundingbox(self, points: np.ndarray) -> dict[str, float]:

Fit a bounding box around a polygon mask.

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

Parse all YOLOv8 splits in a source dataset directory.

Parameters
dataset_dir:PathSource dataset directory containing split folders and one class YAML file.
Returns
tuple[list[Path], list[Path], list[Path]]Added images for the train, validation, and test splits.
Raises
ValueErrorIf the dataset directory does not contain a class YAML file.
def from_split(self, image_dir: Path, annotation_dir: Path, classes_path: Path) -> ParserOutput:

Parse YOLOv8 or Ultralytics annotations into LDF records.

Annotations include object detection, instance segmentation and keypoints.

Parameters
image_dir:PathDirectory with images.
annotation_dir:PathDirectory with annotations.
classes_path:PathYAML file with class names.
Returns
ParserOutputParser output containing annotation records, skeleton metadata, and added images.
@staticmethod
def _detect_dataset_dir_format(dataset_dir: Path) -> tuple[Format | None, list[str]]:

Detect whether a dataset uses Ultralytics or Roboflow layout.