如何将 yolo 注释转换为 coco 格式。杰森?

Nim*_*yan 5 image object-detection annotation-processing data-annotations deep-learning

我想将 yolo 格式的标签转换为 coco 格式我尝试过 https://github.com/Taeyoung96/Yolo-to-COCO-format-converter 和 Pylabel 他们都有一个错误。

我想在 detectorron 2 上进行训练,但由于 json 文件错误,它无法加载数据集。

谢谢大家

Lou*_*Lac 5

您可以使用globox包(免责声明:我是作者)。这应该类似于:

from pathlib import Path

import globox


def main() -> None:
  path = Path("/path/to/annotations/")  # Where the .txt files are
  save_file = Path("coco.json")

  annotations = globox.AnnotationSet.from_yolo(gts_path)
  annotations.save_coco(save_file)


if __name__ == "__main__":
    main()
Run Code Online (Sandbox Code Playgroud)

如果您需要使用文件映射标签.name

names_file = Path("/path/to/classes.names")
names = AnnotationSet.parse_names_file(names_file)
annotations.map_labels(names)
Run Code Online (Sandbox Code Playgroud)

您可以查看其他格式的文档(Yolo Darknet、Yolo v8 等)。