You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从Open Images Dataset V6中获取检测标注坐标数据?

Open Images V6 标注提取解决方案

你已经通过FiftyOne完成了目标类别子集的加载与合并,无需读取体积过大的全量原始detections.csv,直接通过FiftyOne数据集对象的API即可提取所需标注:

方案一:直接导出为通用标注格式

可直接使用FiftyOne内置的导出功能,将标注导出为YOLO、COCO等常用格式,自动生成对应的标注文本文件:

# 导出为YOLO格式(标注为.txt文件,每个图像对应一个标注文件,包含类别ID+归一化坐标)
dataset.export(
    export_dir="./open_images_yolo_labels",
    dataset_type=fo.types.YOLOv5Dataset,
    label_field="detections",
    classes=["Bottle", "Person", "Tin can", "Box"]
)

方案二:自定义提取标注写入文本

如果需要自定义输出格式,可直接遍历数据集样本提取检测框信息:

# 打开输出文件
with open("./detection_labels.txt", "w") as f:
    # 遍历每个样本
    for sample in dataset.iter_samples(autosave=True):
        # 获取图像文件名、宽高
        img_path = sample.filepath
        img_w = sample.metadata.width
        img_h = sample.metadata.height
        # 遍历每个检测框
        for detection in sample.detections.detections:
            # 提取类别、归一化坐标(格式:[x_min, y_min, width, height])
            cls = detection.label
            x_min, y_min, w, h = detection.bounding_box
            # 可转为像素坐标(按需选择)
            x_min_pix = x_min * img_w
            y_min_pix = y_min * img_h
            x_max_pix = x_min_pix + w * img_w
            y_max_pix = y_min_pix + h * img_h
            # 写入文件,格式可自行调整
            f.write(f"{img_path},{cls},{x_min_pix:.2f},{y_min_pix:.2f},{x_max_pix:.2f},{y_max_pix:.2f}\n")

注意事项

  • 导出的标注仅包含你指定的4个类别,无冗余信息,文件体积远小于原始全量detections.csv
  • 若需要其他标注属性(如置信度、标注来源),可直接读取detection对象对应的属性字段即可

内容的提问来源于stack exchange,提问作者Ryotaro Harada

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 08:33:00