class BaseParser(ABC):
Known subclasses: luxonis_ml.data.parsers.ClassificationDirectoryParser, luxonis_ml.data.parsers.COCOParser, luxonis_ml.data.parsers.CreateMLParser, luxonis_ml.data.parsers.DarknetParser, luxonis_ml.data.parsers.FiftyOneClassificationParser, luxonis_ml.data.parsers.NativeParser, luxonis_ml.data.parsers.SegmentationMaskDirectoryParser, luxonis_ml.data.parsers.SOLOParser, luxonis_ml.data.parsers.TensorflowCSVParser, luxonis_ml.data.parsers.UltralyticsNDJSONParser, luxonis_ml.data.parsers.VOCParser, luxonis_ml.data.parsers.YoloV4Parser, luxonis_ml.data.parsers.YoloV6Parser, luxonis_ml.data.parsers.YOLOv8Parser
Constructor: BaseParser(dataset, dataset_type, task_name, full_warnings)
Base class for dataset-format parsers.
| Class Method | discover |
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 |
Validate whether a split directory has the expected format. |
| Method | __init__ |
Create a parser for a target dataset. |
| Method | from |
Parse all data in a source dataset directory. |
| Method | from |
Parse data from one split subdirectory. |
| Method | get |
Return parser issue messages collected during the last parse. |
| Method | parse |
Parse an entire dataset directory into the target dataset. |
| Method | parse |
Parse one split subdirectory into the target dataset. |
| Method | reset |
Clear collected parser issue messages. |
| Static Method | _apply |
Distribute images across splits based on requested counts. |
| Static Method | _apply |
Apply count-based split requests to existing splits. |
| Static Method | _canonicalize |
All current parsers use train and test split names whereas validation splits can vary in name between val valid and validation. |
| Static Method | _compare |
Compare sets of files by stem. |
| Static Method | _get |
Return unique images yielded by a dataset generator. |
| Static Method | _list |
List OpenCV-supported images in a directory. |
| Static Method | _sample |
Sample from each original split independently. |
| Method | _get |
Return parser issue messages collected during the last parse. |
| Method | _log |
Undocumented |
| Method | _parse |
Undocumented |
| Method | _parse |
Parse data in one split subdirectory. |
| Method | _remove |
Remove records that are not assigned to any split. |
| Method | _reset |
Clear collected parser issue messages and warning counters. |
| Method | _warn |
Undocumented |
| Method | _wrap |
Add configured task names to generated records. |
| Constant | _CANONICAL |
Undocumented |
| Constant | _SKIPPED |
Undocumented |
| Constant | _SPLIT |
Undocumented |
| Instance Variable | _dataset |
Undocumented |
| Instance Variable | _dataset |
Undocumented |
| Instance Variable | _full |
Undocumented |
| Instance Variable | _logged |
Undocumented |
| Instance Variable | _parser |
Undocumented |
| Instance Variable | _seen |
Undocumented |
| Instance Variable | _skipped |
Undocumented |
| Instance Variable | _suppressed |
Undocumented |
| Instance Variable | _task |
Undocumented |
luxonis_ml.data.parsers.COCOParser, luxonis_ml.data.parsers.YoloV6Parser, luxonis_ml.data.parsers.YOLOv8ParserReturn present and valid split directories keyed by their canonical split names.
luxonis_ml.data.parsers.COCOParser, luxonis_ml.data.parsers.UltralyticsNDJSONParser, luxonis_ml.data.parsers.YoloV6Parser, luxonis_ml.data.parsers.YOLOv8ParserValidate whether the dataset directory has the expected format.
| Parameters | |
datasetPath | Source dataset directory. |
| Returns | |
bool | Whether the dataset is in the expected format. |
luxonis_ml.data.parsers.ClassificationDirectoryParser, luxonis_ml.data.parsers.COCOParser, luxonis_ml.data.parsers.CreateMLParser, luxonis_ml.data.parsers.DarknetParser, luxonis_ml.data.parsers.FiftyOneClassificationParser, luxonis_ml.data.parsers.NativeParser, luxonis_ml.data.parsers.SegmentationMaskDirectoryParser, luxonis_ml.data.parsers.SOLOParser, luxonis_ml.data.parsers.TensorflowCSVParser, luxonis_ml.data.parsers.UltralyticsNDJSONParser, luxonis_ml.data.parsers.VOCParser, luxonis_ml.data.parsers.YoloV4Parser, luxonis_ml.data.parsers.YoloV6Parser, luxonis_ml.data.parsers.YOLOv8ParserValidate whether a split directory has the expected format.
| Parameters | |
splitPath | Path to a split directory. |
| Returns | |
dict[ | Keyword arguments for from_split, or None if the split is not in the expected format. |
BaseDataset, dataset_type: DatasetType, task_name: str | dict[ str, str] | None, full_warnings: bool = False):
¶
Create a parser for a target dataset.
| Parameters | |
dataset:BaseDataset | Dataset to populate with parsed records. |
datasetDatasetType | Source dataset format. |
taskstr | dict[ | Optional task naming rule. A string is used for all records. A mapping uses class names as keys and task names as values. |
fullbool | Whether to log every skipped-annotation warning. When False, only the first 50 warnings are logged and the rest are summarized. |
Path, **kwargs) -> tuple[ list[ Path], list[ Path], list[ Path]]:
¶
luxonis_ml.data.parsers.ClassificationDirectoryParser, luxonis_ml.data.parsers.COCOParser, luxonis_ml.data.parsers.CreateMLParser, luxonis_ml.data.parsers.DarknetParser, luxonis_ml.data.parsers.FiftyOneClassificationParser, luxonis_ml.data.parsers.NativeParser, luxonis_ml.data.parsers.SegmentationMaskDirectoryParser, luxonis_ml.data.parsers.SOLOParser, luxonis_ml.data.parsers.TensorflowCSVParser, luxonis_ml.data.parsers.UltralyticsNDJSONParser, luxonis_ml.data.parsers.VOCParser, luxonis_ml.data.parsers.YoloV4Parser, luxonis_ml.data.parsers.YoloV6Parser, luxonis_ml.data.parsers.YOLOv8ParserParse all data in a source dataset directory.
| Parameters | |
datasetPath | Source dataset directory. |
| **kwargs | Additional parser-specific arguments. |
| Returns | |
tuple[ | Added images for the train, validation, and test splits. |
luxonis_ml.data.parsers.ClassificationDirectoryParser, luxonis_ml.data.parsers.COCOParser, luxonis_ml.data.parsers.CreateMLParser, luxonis_ml.data.parsers.DarknetParser, luxonis_ml.data.parsers.FiftyOneClassificationParser, luxonis_ml.data.parsers.NativeParser, luxonis_ml.data.parsers.SegmentationMaskDirectoryParser, luxonis_ml.data.parsers.SOLOParser, luxonis_ml.data.parsers.TensorflowCSVParser, luxonis_ml.data.parsers.UltralyticsNDJSONParser, luxonis_ml.data.parsers.VOCParser, luxonis_ml.data.parsers.YoloV4Parser, luxonis_ml.data.parsers.YoloV6Parser, luxonis_ml.data.parsers.YOLOv8ParserParse data from one split subdirectory.
Example
split_kwargs = parser.validate_split(split_path) if split_kwargs is not None: parser.from_split(**split_kwargs)
| Parameters | |
| **kwargs | Parser-specific arguments, usually produced by validate_split. |
| Returns | |
ParserOutput | LDF generator, skeleton metadata, and added images. |
luxonis_ml.data.parsers.UltralyticsNDJSONParserParse an entire dataset directory into the target dataset.
| Parameters | |
datasetPath | Source dataset directory. |
| **kwargs | Parser-specific arguments. |
| Returns | |
BaseDataset | Dataset with parsed images and annotations. |
| Raises | |
ValueError | If a parser that expects top-level splits cannot find a train directory. |
str | None = None, random_split: bool = False, split_ratios: dict[ str, float | int] | None = None, **kwargs) -> BaseDataset:
¶
luxonis_ml.data.parsers.UltralyticsNDJSONParserParse one split subdirectory into the target dataset.
| Parameters | |
split:str | None | Optional split name to assign to parsed data. When set, split_ratios and random_split are ignored. |
randombool | Whether to generate random splits using split_ratios. |
splitdict[ | Optional ratios or counts. Float values are treated as ratios; integer values are treated as counts. |
| **kwargs | Parser-specific arguments. |
| Returns | |
BaseDataset | Dataset with parsed images and annotations. |
Sequence[ PathType], split_ratios: dict[ str, int]) -> dict[ str, Sequence[ PathType]]:
¶
Distribute images across splits based on requested counts.
When total requested exceeds available, fills splits by priority (most requested first).
| Parameters | |
images:Sequence[ | Images to distribute. |
splitdict[ | Requested counts for each split. |
| Returns | |
dict[ | Split names mapped to assigned images. |
dict[ str, Sequence[ PathType]], split_ratios: dict[ str, int]) -> dict[ str, Sequence[ PathType]]:
¶
Apply count-based split requests to existing splits.
Samples from each original split independently. If more samples are requested than available in a split, all available samples from that split are used.
| Parameters | |
originaldict[ | Existing split assignments. |
splitdict[ | Requested counts for each split. |
| Returns | |
dict[ | Split names mapped to assigned images. |
All current parsers use train and test split names whereas validation splits can vary in name between val valid and validation.
This maps valid -> val and validation -> val
Compare sets of files by stem.
Example
>>> BaseParser._compare_stem_files([Path("a.jpg"), Path("b.jpg")], ... [Path("a.xml"), Path("b.xml")]) True >>> BaseParser._compare_stem_files([Path("a.jpg")], [Path("b.txt")]) False
| Parameters | |
list1:Iterable[ | First files to compare. |
list2:Iterable[ | Second files to compare. |
| Returns | |
bool | Whether the non-empty file stem sets are equal. |
Return unique images yielded by a dataset generator.
| Parameters | |
generator:DatasetIterator | Dataset record generator. |
| Returns | |
list[ | Unique added image paths. |
List OpenCV-supported images in a directory.
| Parameters | |
imagePath | Directory with images. |
| Returns | |
list[ | Supported image paths. |
dict[ str, Sequence[ PathType]], split_ratios: dict[ str, int]) -> dict[ str, Sequence[ PathType]]:
¶
Sample from each original split independently.
| Parameters | |
originaldict[ | Existing split assignments. |
splitdict[ | Requested counts for each split. |
| Returns | |
dict[ | Split names mapped to sampled images. |
Parse data in one split subdirectory.
| Parameters | |
| **kwargs | Parser-specific arguments. |
| Returns | |
list[ | Added images. |
ParserIssue, reason: str, *, source: PathType | None = None, image: PathType | None = None, annotation_id: str | int | None = None):
¶
Undocumented
Add configured task names to generated records.
| Parameters | |
generator:DatasetIterator | Dataset record generator. |
| Returns | |
DatasetIterator | Generator that yields records with task names applied. |
luxonis_ml.data.parsers.FiftyOneClassificationParser, luxonis_ml.data.parsers.NativeParserUndocumented
| Value |
|