实例分割数据集概览
实例分割是一项计算机视觉任务,旨在识别并勾勒图像中的各个独立物体。本指南概述了 Ultralytics YOLO 支持的实例分割数据集格式,并说明如何准备、转换和使用这些数据集来训练模型。
支持的数据集格式#
Ultralytics YOLO 格式#
用于训练 YOLO 分割模型的数据集标签格式如下:
- 每张图像对应一个文本文件:数据集中的每张图像都有一个对应的文本文件,文件名与图像文件相同,扩展名为“.txt”。
- 每个物体占一行:文本文件中的每一行对应图像中的一个物体实例。
- 每行包含物体信息:每一行包含有关该物体实例的以下信息:
- 物体类别索引:表示物体类别的整数(例如,0 表示 person,1 表示 car,依此类推)。
- 物体多边形坐标:
(x, y)点用于勾勒物体掩码,坐标归一化到 0 到 1 之间。
分割数据集文件中单行的格式如下:
<class-index> <x1> <y1> <x2> <y2> ... <xn> <yn>在此格式中,<class-index> 是物体的类别索引,<x1> <y1> <x2> <y2> ... <xn> <yn> 是物体分割掩码的归一化多边形坐标(数值相对于图像宽度和高度,范围为 [0, 1])。坐标之间以空格分隔。
以下示例展示了单张图像对应的 YOLO 数据集格式,其中包含两个物体,分别由 3 个点和 5 个点组成的分割区域构成。
0 0.681 0.485 0.670 0.487 0.676 0.487
1 0.504 0.000 0.501 0.004 0.498 0.004 0.493 0.010 0.492 0.0104- 每一行的长度不必相同。
- 每个分割标签必须至少包含 3 个
(x, y)点:<class-index> <x1> <y1> <x2> <y2> <x3> <y3> - 每个对象都需要一个多边形。检测格式的行(
<class-index> <x_center> <y_center> <width> <height>)不包含多边形;如果分割数据集中的边界框数量和多边形数量不一致,加载标签时就会报错ValueError。
数据集 YAML 格式#
Ultralytics 框架使用 YAML 文件格式定义用于训练分割模型的数据集和模型配置。以下是定义分割数据集所用 YAML 格式的示例:
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
# COCO8-seg dataset (first 8 images from COCO train2017) by Ultralytics
# Documentation: https://docs.ultralytics.com/datasets/segment/coco8-seg
# Example usage: yolo train data=coco8-seg.yaml
# parent
# ├── ultralytics
# └── datasets
# └── coco8-seg ← downloads here (1 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco8-seg # dataset root dir
train: images/train # train images (relative to 'path') 4 images
val: images/val # val images (relative to 'path') 4 images
test: # test images (optional)
# Classes
names:
0: person
1: bicycle
2: car
3: motorcycle
4: airplane
5: bus
6: train
7: truck
8: boat
9: traffic light
10: fire hydrant
11: stop sign
12: parking meter
13: bench
14: bird
15: cat
16: dog
17: horse
18: sheep
19: cow
20: elephant
21: bear
22: zebra
23: giraffe
24: backpack
25: umbrella
26: handbag
27: tie
28: suitcase
29: frisbee
30: skis
31: snowboard
32: sports ball
33: kite
34: baseball bat
35: baseball glove
36: skateboard
37: surfboard
38: tennis racket
39: bottle
40: wine glass
41: cup
42: fork
43: knife
44: spoon
45: bowl
46: banana
47: apple
48: sandwich
49: orange
50: broccoli
51: carrot
52: hot dog
53: pizza
54: donut
55: cake
56: chair
57: couch
58: potted plant
59: bed
60: dining table
61: toilet
62: tv
63: laptop
64: mouse
65: remote
66: keyboard
67: cell phone
68: microwave
69: oven
70: toaster
71: sink
72: refrigerator
73: book
74: clock
75: vase
76: scissors
77: teddy bear
78: hair drier
79: toothbrush
# Download script/URL (optional)
download: https://github.com/ultralytics/assets/releases/download/v0.0.0/coco8-seg.ziptrain、val 和 test 字段分别指向训练、验证和测试图像。每个字段均接受目录、图像文件、目录或图像文件列表,或 UTF-8 *.txt 文件;该文件每行列出一个图像路径(以 ./ 开头的路径将相对于 *.txt 文件解析)。使用 *.txt 文件可以基于目录的子集进行训练、跳过未标注的图像,或将来自多个来源的图像合并到一个数据集划分中。
path: datasets/coco8-seg # dataset root
train: train.txt # a directory, an image, a list e.g. [images/a, images/b], or a *.txt file
val: val.txt
names:
0: personnames 是一个类别名称字典。名称的顺序应与 YOLO 数据集文件中对象类别索引的顺序一致。
用法#
from ultralytics import YOLO
# 加载模型
model = YOLO("yolo26n-seg.pt") # 加载预训练模型(推荐用于训练)
# 训练模型
results = model.train(data="coco8-seg.yaml", epochs=100, imgsz=640)支持的数据集#
Ultralytics YOLO 支持多种用于实例分割任务的数据集。以下是最常用的数据集列表。其中大多数数据集也托管在 Ultralytics Platform 上,你可以浏览图像和标注、查看数据集统计信息,并克隆数据集以进行云端训练。
- Carparts-seg:这是一个专注于汽车零部件分割的专用数据集,非常适合汽车应用。它包含各种车辆,并对各个汽车部件进行了详细标注。
- COCO:这是一个全面的数据集,可用于目标检测、分割和图像描述,涵盖广泛类别的 20 多万张标注图像。
- COCO8-seg:这是 COCO 中一个包含 8 张图像的小型子集,专为快速测试分割模型训练而设计,非常适合在
ultralytics仓库中进行 CI 检查和工作流验证。 - COCO128-seg:一个用于实例分割任务的小型数据集,包含 COCO 中 128 张带分割标注的图像子集。
- Crack-seg:这是一个针对各种表面裂缝分割的数据集。它对基础设施维护和质量控制至关重要,提供了详细图像,可用于训练模型识别结构缺陷。
- Package-seg:这是一个专门用于分割不同类型包装材料和形状的数据集。它尤其适用于物流和仓库自动化,有助于开发包裹处理和分拣系统。
添加你自己的数据集#
如果你有自己的数据集,并希望使用 Ultralytics YOLO 格式训练分割模型,请确保数据集遵循上文“Ultralytics YOLO 格式”部分指定的格式。将标注转换为所需格式,并在 YAML 配置文件中指定路径、类别数量和类别名称。将 images/ 和 labels/ 保持为同级的独立文件夹,并确保子文件夹结构一致;将标签 .txt 文件放入图像文件夹可能导致模型漏掉标签。
转换或迁移标签格式#
将 COCO 数据集格式转换为 YOLO 格式#
你可以使用以下代码片段,将常见的 COCO 数据集格式标签转换为 YOLO 格式:
from ultralytics.data.converter import convert_coco
convert_coco(labels_dir="path/to/coco/annotations/", use_segments=True)你可以使用此转换工具,将 COCO 数据集或任何 COCO 格式的数据集转换为 Ultralytics YOLO 格式。
请记得仔细检查你要使用的数据集是否与你的模型兼容,以及是否遵循必要的格式规范。格式正确的数据集对于成功训练分割模型至关重要。
自动标注#
自动标注可通过预训练检测模型生成分割数据集,因此你无需手动绘制每个掩码,就能标注大量图像。如需直接在浏览器中标注,Ultralytics Platform 提供 SAM、YOLO 和类别提示智能标注,而 VLM 排行榜则会比较提示式模型的检测准确率、成本和速度。
使用检测模型生成分割数据集#
要使用 Ultralytics 框架自动标注数据集,你可以按如下方式使用 auto_annotate 函数:
from ultralytics.data.annotator import auto_annotate
auto_annotate(data="path/to/images", det_model="yolo26x.pt", sam_model="sam_b.pt")| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
data | str | 必需 | 包含待标注或分割目标图像的目录路径。 |
det_model | str | 'yolo26x.pt' | 用于初始对象检测的 YOLO 检测模型路径。 |
sam_model | str | 'sam_b.pt' | 用于分割的 SAM 模型路径(支持 SAM、SAM 2、MobileSAM 和 SAM 3 权重)。 |
device | str | '' | 计算设备(例如 'cuda:0'、'cpu',或 '' 表示自动检测设备)。 |
conf | float | 0.25 | 用于过滤低置信度检测结果的 YOLO 检测置信度阈值。 |
iou | float | 0.5 | 用于通过非极大值抑制过滤重叠框的 IoU 阈值。 |
imgsz | int | 640 | 图像缩放输入尺寸(如有需要,会向上取整为 32 的倍数)。 |
max_det | int | 300 | 为提高内存效率,每张图像的最大检测数。 |
classes | list[int] | None | 要检测的类别索引列表(例如,[0, 1] 表示人和自行车)。 |
output_dir | str | None | 标注结果的保存目录(默认:同级目录中的 <data>_auto_annotate_labels)。 |
auto_annotate 函数接收图像路径,以及用于指定预训练检测模型的可选参数,例如 YOLO26、YOLO11 或其他模型,以及分割模型,例如 SAM、SAM 2、MobileSAM 或 SAM 3,还可以指定运行模型的设备,以及保存标注结果的输出目录。
借助预训练模型,自动标注显著减少了创建高质量分割数据集所需的时间和精力。这对处理大型图像集合的研究人员和开发者尤其有用,因为他们可以专注于模型开发和评估,而不是手动标注。
可视化数据集注释#
训练模型之前,通常最好先可视化数据集标注,确保标注正确。Ultralytics 提供了一个用于此目的的实用函数。此函数只读取检测格式的边界框标签(<class-index> <x_center> <y_center> <width> <height>),因此无法解析分割多边形标签文件:
from ultralytics.data.utils import visualize_image_annotations
label_map = { # 定义包含所有已注释类别标签的标签映射。
0: "person",
1: "car",
}
# Visualize
visualize_image_annotations(
"path/to/image.jpg", # 输入图像路径。
"path/to/annotations.txt", # 图像的注释文件路径。
label_map,
)此函数会绘制边界框,使用类别名称标记对象,并调整文本颜色以提高可读性,帮助你在训练前发现并修正标注错误。
将分割掩码转换为 YOLO 格式#
如果你有灰度掩码图像,其中每个像素值等于类别索引 + 1(0 表示背景),可以使用以下方法将其转换为 YOLO 分割格式:
from ultralytics.data.converter import convert_segment_masks_to_yolo_seg
# 适用于 COCO 等包含 80 个类别的数据集
convert_segment_masks_to_yolo_seg(masks_dir="path/to/masks_dir", output_dir="path/to/output_dir", classes=80)此实用工具会将掩码图像转换为 YOLO 分割格式,并保存到指定的输出目录。
常见问题#
Ultralytics YOLO 支持多种实例分割数据集格式,其中主要格式是其自有的 Ultralytics YOLO 格式。数据集中的每张图像都需要对应一个文本文件,其中的对象信息按多行分段(每个对象占一行),列出类别索引和归一化多边形坐标。
借助 Ultralytics 工具,将 COCO 格式的标注转换为 YOLO 格式非常简单。你可以使用
ultralytics.data.converter模块中的convert_coco函数:from ultralytics.data.converter import convert_coco convert_coco(labels_dir="path/to/coco/annotations/", use_segments=True)此脚本会将你的 COCO 数据集标注转换为所需的 YOLO 格式,使其适用于训练 YOLO 模型。如需了解详情,请参阅迁移或转换标签格式。
要使用 Ultralytics 准备 YOLO 模型训练所需的 YAML 文件,你需要定义数据集路径和类别名称。以下是 YAML 配置示例:
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license # COCO8-seg dataset (first 8 images from COCO train2017) by Ultralytics # Documentation: https://docs.ultralytics.com/datasets/segment/coco8-seg # Example usage: yolo train data=coco8-seg.yaml # parent # ├── ultralytics # └── datasets # └── coco8-seg ← downloads here (1 MB) # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..] path: coco8-seg # dataset root dir train: images/train # train images (relative to 'path') 4 images val: images/val # val images (relative to 'path') 4 images test: # test images (optional) # Classes names: 0: person 1: bicycle 2: car 3: motorcycle 4: airplane 5: bus 6: train 7: truck 8: boat 9: traffic light 10: fire hydrant 11: stop sign 12: parking meter 13: bench 14: bird 15: cat 16: dog 17: horse 18: sheep 19: cow 20: elephant 21: bear 22: zebra 23: giraffe 24: backpack 25: umbrella 26: handbag 27: tie 28: suitcase 29: frisbee 30: skis 31: snowboard 32: sports ball 33: kite 34: baseball bat 35: baseball glove 36: skateboard 37: surfboard 38: tennis racket 39: bottle 40: wine glass 41: cup 42: fork 43: knife 44: spoon 45: bowl 46: banana 47: apple 48: sandwich 49: orange 50: broccoli 51: carrot 52: hot dog 53: pizza 54: donut 55: cake 56: chair 57: couch 58: potted plant 59: bed 60: dining table 61: toilet 62: tv 63: laptop 64: mouse 65: remote 66: keyboard 67: cell phone 68: microwave 69: oven 70: toaster 71: sink 72: refrigerator 73: book 74: clock 75: vase 76: scissors 77: teddy bear 78: hair drier 79: toothbrush # Download script/URL (optional) download: https://github.com/ultralytics/assets/releases/download/v0.0.0/coco8-seg.zip请根据你的数据集更新路径和类别名称。如需了解详情,请查看数据集 YAML 格式部分。
Ultralytics YOLO 的自动标注功能可以使用预训练检测模型为数据集生成分割标注,大幅减少手动标注的需求。你可以按如下方式使用
auto_annotate函数:from ultralytics.data.annotator import auto_annotate auto_annotate(data="path/to/images", det_model="yolo26x.pt", sam_model="sam_b.pt") # or sam_model="mobile_sam.pt"此函数可自动执行标注流程,使其更快速、更高效。如需了解详情,请参阅自动标注参考。
评论80
提出问题、分享结果,或帮助其他人。
hp0716
Hello, currently my segmentation task requires multi-channel masking, which means that one pixel may belong to multiple categories. Is there any code that implements this feature? Looking forward to receiving your reply.
1kh-diab
hello i tried to convert coco format to yolo format in segmented images but the generated yolo files are empty
from ultralytics.data.converter import convert_coco
convert_coco(labels_dir="groupC/annotations", use_segments=True)
can you tell me
this is example of the original annotation file exported from CVAT to coco format knowing that I used SAM model to do the segmentation
{ "id": 16, "image_id": 10, "category_id": 1, "segmentation": { "counts": [ 2815839, 2, 1817, 5, 1814, 7, 1812, 8, 1810, 10, 1809, 11, 1807, 14, 1805, 15, 1803, 17, 1802, 18, 1801, 18, 1800, 19, 1800, 19, 1800, 19, 1800, 20, 1798, 21, 1798, 21, 1798, 22, 1796, 23, 1796, 23, 1797, 23, 1796, 23, 1796, 23, 1796, 23, 1796, 23, 1797, 23, 1796, 23, 1797, 22, 1797, 23, 1797, 22, 1797, 23, 1797, 22, 1797, 22, 1798, 22, 1798, 21, 1798, 22, 1798, 21, 1798, 22, 1798, 21, 1799, 21, 1798, 21, 1799, 21, 1800, 19, 1801, 18, 1803, 15, 1807, 10, 829643 ], "size": [ 1820, 2048 ] }, "area": 861.0, "bbox": [ 1547.0, 263.0, 46.0, 42.0 ], "iscrowd": 1, "attributes": { "occluded": false } },
1
Glenn JocherUltralytics@kh-diab it seems like the conversion process isn't working as expected. Please ensure that your COCO annotations are correctly formatted and that the
use_segments=Trueparameter is set. Also, make sure you're using the latest version of the Ultralytics package. If the issue persists, try running the conversion with a smaller subset of your data to isolate the problem. For more detailed guidance, you can refer to the Instance Segmentation Datasets Overview.
ratom
I have semantic segmentation data of 6 classes. But the dataset has one folder for images and another folder for segmentation mask. I have color maps for each mask and each class. In this case, I want to create a dataset for YOLO style segmentation. How can I do it.
rohith-aiunika
hi yolo team, can i perform object tracking for my segmentation model using this kind of annotation format ... or do i need x_center, y_center, width, height ... format?
Glenn JocherUltralytics@rohith-aiunika the annotation format
<class-index> <x1> <y1> <x2> <y2> ... <xn> <yn>is sufficient for segmentation tasks, including object tracking with segmentation models, as long as it aligns with the Ultralytics YOLO format. The additional fields for bounding boxes (e.g.,x_center, y_center, width, height) are not required unless explicitly specified for other tasks. For more details, you can refer to Instance Segmentation Datasets Overview.
mathrank
What should I do if the object has a hole in the center?
Glenn JocherUltralytics(已编辑)@mathrank each row in a segmentation label file is a single polygon, so a hole cannot be a separate row (it would be read as a second object). Instead, join the outer and inner boundaries into one polygon by connecting them with a thin bridge between their closest points, which is how the COCO converter (
merge_multi_segment) merges multi-part segments. For details on the format, refer to Instance Segmentation Datasets Overview.
johnlockejrr
Finally I ended up with the following code, any opinion?
from ultralytics import YOLO import cv2 import numpy as np from pathlib import Path image_path = "/home/incognito/yolov8/datasets/sam_v1/images/a34e234a-76be-5392-9b39-4abdcd051719.jpg" # Load the YOLOv8 model model = YOLO('/home/incognito/yolov8/runs/segment/train/weights/best.pt') # Perform inference on an image results = model(image_path) img = cv2.imread(image_path) img_name = Path(image_path).stem # Extract bounding boxes, classes, names, and confidences boxes = results[0].boxes.xyxy.tolist() classes = results[0].boxes.cls.tolist() names = results[0].names confidences = results[0].boxes.conf.tolist() bboxes = [] # Iterate through the results for box, cls, conf in zip(boxes, classes, confidences): x1, y1, x2, y2 = box confidence = conf detected_class = cls name = names[int(cls)] bboxes.append(box) #print(f"class: {name}, box: {box}") bboxes.sort(key=lambda x: x[0]) for number, bbox in enumerate(bboxes): print(bbox) x1, y1, x2, y2 = bbox iso_crop = img[int(y1):int(y2), int(x1):int(x2)] cv2.imwrite(f"{img_name}_{number}.jpg", iso_crop)johnlockejrr
90% ok, most of the lines are in the correct position, some are not... I sorted by
x1, was I wrong?
Glenn JocherUltralytics@johnlockejrr sorting by
x1is fine if you want to order the bounding boxes from left to right. Ensure this aligns with your intended use case. If you need further assistance, feel free to ask! For more on dataset formats, visit the Ultralytics documentation.
johnlockejrr(已编辑)
Yes, you are right, the solution is here https://docs.ultralytics.com/guides/isolating-segmentation-objects/#what-options-are-available-for-saving-the-isolated-objects-after-segmentation. Here is my code that does that (for anyone interested):
from pathlib import Path import cv2 import numpy as np from ultralytics import YOLO m = YOLO("/home/incognito/yolov8/runs/segment/train/weights/best.pt") res = m.predict("/home/incognito/yolov8/datasets/sam_v1/images/a34e234a-76be-5392-9b39-4abdcd051719.jpg") # Iterate detection results for r in res: img = np.copy(r.orig_img) img_name = Path(r.path).stem # Iterate each object contour for ci, c in enumerate(r): label = c.names[c.boxes.cls.tolist().pop()] b_mask = np.zeros(img.shape[:2], np.uint8) # Create contour mask contour = c.masks.xy.pop().astype(np.int32).reshape(-1, 1, 2) _ = cv2.drawContours(b_mask, [contour], -1, (255, 255, 255), cv2.FILLED) # Choose one: # OPTION-1: Isolate object with black background mask3ch = cv2.cvtColor(b_mask, cv2.COLOR_GRAY2BGR) isolated = cv2.bitwise_and(mask3ch, img) # OPTION-2: Isolate object with transparent background (when saved as PNG) #isolated = np.dstack([img, b_mask]) # OPTIONAL: detection crop (from either OPT1 or OPT2) x1, y1, x2, y2 = c.boxes.xyxy.cpu().numpy().squeeze().astype(np.int32) iso_crop = isolated[y1:y2, x1:x2] cv2.imwrite(f"{img_name}_{ci}.jpg", iso_crop)The only problem is that the lines in page are random and not top-down in order. Is there a way to have them in order? As I read the
ultralyticscode the result is sorted by confidence (torch.argsort(scores, descending=True)), this, for segmenting lines of text in a page isn't helping, I should be able to sort it by masks location, from top down and left to right or right to left.
Glenn JocherUltralytics@johnlockejrr to sort the results by mask location, you can modify your code to sort based on the bounding box coordinates. Extract the y-coordinate of the bounding boxes and sort the results accordingly. This will help you achieve a top-down order. If you need further assistance, feel free to ask!
johnlockejrr
Yes, I got it, but that I'm not sure how to do it, didn't find anything in the docs
Glenn JocherUltralyticsTo sort the segmented objects by their location, you can modify your code to sort based on the y-coordinate of the bounding boxes. This will help you achieve a top-down order. If you need further assistance, feel free to ask!
johnlockejrr
@glenn-jocher, thank you for your help! I trained the model already and works pretty well, right now trying to figure out how to predict with it, I mean how to get back polygons so I forward them to a line recognition HTR (like PyLaia) for text recognition. I need to use the segmentation so I can cut the lines of text from the segmented image.
My script:
from ultralytics import YOLO # https://docs.ultralytics.com/modes/predict/#inference-arguments # Load a model model = YOLO("/home/incognito/yolov8/runs/segment/train4/weights/best.pt") # pretrained YOLOv8n model # Run batched inference on a list of images results = model("29.jpg") # return a list of Results objects # Process results list for result in results: boxes = result.boxes # Boxes object for bounding box outputs masks = result.masks # Masks object for segmentation masks outputs keypoints = result.keypoints # Keypoints object for pose outputs probs = result.probs # Probs object for classification outputs obb = result.obb # Oriented boxes object for OBB outputs result.show() # display to screen result.save(filename="result.jpg") # save to diskMy
result.jpg
Glenn JocherUltralytics@johnlockejrr to extract polygons for line recognition, you can access the
masksattribute in your results. This will give you the segmentation masks, which you can then process to obtain the polygon coordinates needed for your HTR system. If you need further details, please refer to the documentation on segmentation results processing.
johnlockejrr
Thank you @glenn-jocher, I converted my data with
page2darknetto darknet format then I converted it to YOLO OBB.johnlockejrr(已编辑)
I'm new to YOLO. I would like to convert my datasets for training a YOLOv8 model. My datasets are mainly in ALTO XML and PAGE XML formats (image/xml), the xml file contains polygons, any idea how to convert to YOLO format? Thank you!
Example:
<TextLine ID="eSc_line_48be6c40" TAGREFS="LT46" BASELINE="627 397 964 397 1713 373 2473 373" HPOS="625" VPOS="338" WIDTH="1848" HEIGHT="87"> <Shape><Polygon POINTS="2470 351 2454 351 2438 349 2422 349 2407 348 2391 348 2375 346 2359 346 2344 345 2328 345 2312 343 2296 343 2281 343 2274 342 2254 345 2184 338 2183 338 2181 338 2158 349 2156 349 2139 349 1986 342 1984 342 1983 342 1959 349 1868 338 1855 340 1839 340 1823 340 1808 342 1792 342 1776 342 1775 342 1700 346 1655 345 1650 346 1634 346 1618 346 1603 346 1587 348 1571 348 1555 348 1540 349 1524 349 1508 349 1492 351 1477 351 1461 351 1445 351 1429 353 1414 353 1398 353 1382 354 1366 354 1350 354 1335 356 1319 356 1303 356 1287 356 1272 357 1256 357 1240 357 1224 359 1209 359 1193 359 1179 359 1179 360 1161 365 966 365 956 367 941 367 925 367 909 368 893 368 878 368 862 370 846 370 830 370 815 370 799 368 788 365 646 365 641 368 625 370 627 397 627 425 734 423 736 423 780 412 846 420 848 420 1111 419 1112 417 1295 403 1377 409 1379 409 1380 409 1410 400 1741 397 1820 397 1842 406 1844 406 1845 406 1847 406 1886 406 2128 397 2148 401 2159 403 2161 403 2162 403 2167 401 2184 392 2470 395 2473 373 2471 351 2470 351"/></Shape> <String CONTENT="את הארון ואת בדיו ואת הכפרת ואת פרכת המסך" HPOS="625" VPOS="338" WIDTH="1848" HEIGHT="87"></String> </TextLine>EDIT: I think this should do it:
https://github.com/mittagessen/page2darknet
Glenn JocherUltralytics@johnlockejrr to convert your ALTO XML and PAGE XML datasets to the YOLO format, you'll need to extract the polygon coordinates and class indices, then format them as
<class-index> <x1> <y1> <x2> <y2> ... <xn> <yn>. You might find thepage2darknettool helpful for this conversion. Once converted, ensure your dataset follows the YOLO format with a corresponding YAML file for training. For more details, you can refer to the Ultralytics documentation on dataset formats.1
