class documentation

Detect a dataset format and dispatch to the matching parser.

The parser accepts local paths, remote paths supported by LuxonisFileSystem, ZIP archives, and Roboflow dataset URLs in roboflow://workspace/project/version/format form. If dataset_type is omitted, parsers are tried until one validates the dataset directory as either a full directory or a single split.

Method __init__ High-level abstraction over various parsers.
Method get_parser_issue_messages Return parser issue messages collected during the last parse.
Method parse Parse the dataset and return it in LDF format.
Static Method _download_roboflow_dataset Undocumented
Static Method _download_ultralytics_dataset Undocumented
Static Method _resolve_extracted_zip_root Undocumented
Method _get_parser_issue_messages Return parser issue messages collected during the last parse.
Method _infer_parser_type_for_explicit_type Undocumented
Method _recognize_dataset Recognize the dataset format and parser type.
Instance Variable _dataset Dataset instance populated by parsing.
Instance Variable _dataset_constructor Dataset class resolved from the plugin registry, or LuxonisDataset.
Instance Variable _dataset_dir Local dataset directory used for parsing.
Instance Variable _dataset_type Recognized or user-provided dataset type.
Instance Variable _parser Concrete parser instance selected for dataset_type.
Instance Variable _parser_type Whether dataset_dir represents a full directory or a single split.
Instance Variable _parsers Dataset types mapped to concrete parser classes.
def __init__(self, dataset_dir: str, *, dataset_name: str | None = None, save_dir: Path | str | None = None, dataset_plugin: T = None, dataset_type: DatasetType | None = None, task_name: str | dict[str, str] | None = None, full_warnings: bool = False, **kwargs):

High-level abstraction over various parsers.

Automatically recognizes the dataset format and uses the appropriate parser.

Parameters
dataset_dir:str

Dataset directory identifier. Can be one of:

  • Local path to the dataset directory.
  • Remote URL supported by L{LuxonisFileSystem}.
    • gcs:// for Google Cloud Storage
    • s3:// for Amazon S3
  • roboflow:// for Roboflow datasets.
    • Expected format: roboflow://workspace/project/version/format.
  • ultralytics:// for Ultralytics Platform datasets.
    • Expected format: ultralytics://username/datasets/slug
    • Optional version: append ?v=<version> to export a specific dataset version.
dataset_name:str | NoneOptional output dataset name. If omitted, the name is derived from dataset_dir.
save_dir:Path | str | NoneOptional directory used when downloading remote datasets. If omitted, the current working directory is used.
dataset_plugin:TOptional dataset plugin registry name. If omitted, LuxonisDataset is used.
dataset_type:DatasetType | NoneOptional dataset type. If provided, automatic format recognition is skipped.
task_name:str | dict[str, str] | NoneOptional task naming rule. A string is used for all records. A mapping uses class names as keys and task names as values.
full_warnings:boolWhether all skipped annotation warnings should be logged without truncation.
**kwargsAdditional arguments passed to the selected dataset constructor.
Raises
RuntimeErrorIf a Roboflow URL is used and ROBOFLOW_API_KEY is not configured.
ValueErrorIf a Roboflow URL is malformed, its version is not an integer, or the dataset format cannot be recognized.
def get_parser_issue_messages(self) -> list[ParserIssueMessage]:

Return parser issue messages collected during the last parse.

@overload
def parse(self: LuxonisParser[str], **kwargs) -> BaseDataset:
@overload
def parse(self: LuxonisParser[None], **kwargs) -> LuxonisDataset:

Parse the dataset and return it in LDF format.

If the dataset already exists, parsing will be skipped and the existing dataset will be returned instead.

Parameters
**kwargsParser-specific arguments.
Returns
BaseDatasetParsed dataset.
Raises
ValueErrorIf the selected parser rejects the dataset structure or split arguments.
@staticmethod
def _download_roboflow_dataset(dataset_dir: str, local_path: Path | None) -> tuple[Path, str]:

Undocumented

@staticmethod
def _download_ultralytics_dataset(dataset_dir: str, local_path: Path | None) -> tuple[Path, str]:

Undocumented

@staticmethod
def _resolve_extracted_zip_root(unzip_dir: Path) -> Path:

Undocumented

def _get_parser_issue_messages(self) -> list[ParserIssueMessage]:

Return parser issue messages collected during the last parse.

def _infer_parser_type_for_explicit_type(self, dataset_type: DatasetType) -> ParserType:

Undocumented

def _recognize_dataset(self) -> tuple[DatasetType, ParserType]:

Recognize the dataset format and parser type.

Returns
tuple[DatasetType, ParserType]Dataset type and parser type.
_dataset =

Dataset instance populated by parsing.

_dataset_constructor =

Dataset class resolved from the plugin registry, or LuxonisDataset.

_dataset_dir =

Local dataset directory used for parsing.

_dataset_type =

Recognized or user-provided dataset type.

_parser =

Concrete parser instance selected for dataset_type.

_parser_type =

Whether dataset_dir represents a full directory or a single split.

_parsers: dict[DatasetType, type[BaseParser]] =

Dataset types mapped to concrete parser classes.