fiftyone_classification_parser
最后更新
luxonis_ml.data.parsers.fiftyone_classification_parser类
FiftyOneClassificationParser
Text
1dataset_dir/
2├── train/
3│ ├── data/
4│ │ ├── img1.jpg
5│ │ └── ...
6│ └── labels.json
7├── validation/
8│ ├── data/
9│ └── labels.json
10└── test/
11 ├── data/
12 └── labels.jsonText
1dataset_dir/
2├── data/
3│ ├── img1.jpg
4│ └── ...
5└── labels.jsonText
1{
2 "classes": ["class1", "class2", ...],
3 "labels": {
4 "image_stem": class_index,
5 ...
6 }
7}方法
from_dir
Python
1def from_dir(dataset_dir: Path, **kwargs) -> tuple[list[Path], list[Path], list[Path]]:dataset_dir(Path): 源数据集目录。**kwargs: 其他解析器特定参数。
tuple[list[Path], list[Path], list[Path]]: 训练、验证和测试拆分中添加的图像。
from_split
Python
1def from_split(split_path: Path) -> ParserOutput:示例
Pycon
1split_kwargs = parser.validate_split(split_path)
2if split_kwargs is not None:
3 parser.from_split(**split_kwargs)split_path(Path)**kwargs: 解析器特定参数,通常由validate_split生成。
ParserOutput: LDF 生成器、骨架元数据和添加的图像。
validate_split
Python
1def validate_split(split_path: Path) -> dict[str, Any] | None:split_path(Path): 拆分目录的路径。
dict[str, Any] | None:from_split的关键字参数,如果拆分不是预期格式,则为None。
函数
clean_imagenet_annotations
Python
1def clean_imagenet_annotations(labels_path: Path) -> Path:- 第一个
"crane"(鸟)变为"crane bird",将其与起重机区分开来; - 第二个
"maillot"变为"maillot swim suit"; - 图像
006742从索引 517 移动到索引 134; - 图像
031933从索引 639 移动到索引 638。
labels_fixed.json,并在未更改任何内容时返回原始路径。注意
FiftyOneClassificationParser 仅对平面布局运行此清理。当目录名不是
train、validation 或 test 时,它将拆分视为平面,因此基于拆分的数据集保持其标签不变。labels_path(Path):labels.json的路径。
Path: 清理后的标签文件的路径。