此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 类
  • Format
  • YOLOv8Parser
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

yolov8_parser

最后更新
Python API: luxonis_ml.data.parsers.yolov8_parser

类

Format

YOLOv8 目录布局变体。

属性

ROBOFLOW
Roboflow 分割布局。
ULTRALYTICS
Ultralytics images/labels 布局。

YOLOv8Parser

将 YOLOv8 和 Ultralytics 注释解析为 LDF。预期格式:
Text
1dataset_dir/
2├── images/
3│   ├── train/
4│   │   ├── img1.jpg
5│   │   ├── img2.jpg
6│   │   └── ...
7│   ├── val/
8│   └── test/
9├── labels/
10│   ├── train/
11│   │   ├── img1.txt
12│   │   ├── img2.txt
13│   │   └── ...
14│   ├── val/
15│   └── test/
16└── *.yaml
17
18OR::
19
20dataset_dir/
21├── train/
22│   ├── images/
23│   │   ├── img1.jpg
24│   │   ├── img2.jpg
25│   │   └── ...
26│   ├── labels/
27│   │   ├── img1.txt
28│   │   ├── img2.txt
29│   │   └── ...
30├── valid/
31│   ├── images/
32│   │   ├── img1.txt
33│   │   ├── img2.txt
34│   │   └── ...
35│   ├── labels/
36│   │   ├── img1.txt
37│   │   ├── img2.txt
38│   │   └── ...
39├── test/
40│   ├── images/
41│   │   ├── img1.txt
42│   │   ├── img2.txt
43│   │   └── ...
44│   ├── labels/
45│   │   ├── img1.txt
46│   │   ├── img2.txt
47│   │   └── ...
48└── *.yaml
*.yaml 包含所有类名。这是 Roboflow 可以生成的一种格式。

方法

discover_dir_splits
Python
1def discover_dir_splits(dataset_dir: Path) -> dict[str, dict[str, Any]]:
返回按其规范分割名称键入的现有且有效的分割目录。
fit_boundingbox
Python
1def fit_boundingbox(points: np.ndarray) -> dict[str, float]:
围绕多边形掩码拟合一个边界框。
from_dir
Python
1def from_dir(dataset_dir: Path) -> tuple[list[Path], list[Path], list[Path]]:
解析源数据集目录中的所有 YOLOv8 分割。参数
  • dataset_dir (Path): 包含分割文件夹和一个类 YAML 文件的源数据集目录。
返回
  • tuple[list[Path], list[Path], list[Path]]: 训练、验证和测试分割的添加图像。
引发
  • ValueError: 如果数据集目录不包含类 YAML 文件。
from_split
Python
1def from_split(image_dir: Path, annotation_dir: Path, classes_path: Path) -> ParserOutput:
将 YOLOv8 或 Ultralytics 注释解析为 LDF 记录。注释包括对象检测、实例分割和关键点。参数
  • image_dir (Path): 包含图像的目录。
  • annotation_dir (Path): 包含注释的目录。
  • classes_path (Path): 包含类名的 YAML 文件。
返回
  • ParserOutput: 包含注释记录、骨架元数据和添加图像的解析器输出。
validate
Python
1def validate(dataset_dir: Path) -> bool:
验证数据集目录是否具有预期格式。参数
  • dataset_dir (Path): 源数据集目录。
返回
  • bool: 数据集是否为预期格式。
validate_split
Python
1def validate_split(split_path: Path) -> dict[str, Any] | None:
验证分割目录是否具有预期格式。参数
  • split_path (Path): 分割目录的路径。
返回
  • dict[str, Any] | None: from_split 的关键字参数,如果分割不是预期格式,则为 None。