如何将Yolo注释转换为可可格式。 json?

发布于 2025-01-19 23:36:14 字数 323 浏览 1 评论 0原文

我想以yolo格式将标签转换为可可格式 我尝试过 https://github.com/github.com/taeyoung96/yolo-to-coco-format-to-coco-format--coco-format--coco-format--转换器 和 Pylabel 他们都有一个错误。

我想在检测2上训练,但是由于错误的JSON文件,它无法加载数据集。

I want to convert my labels in yolo format to coco format
I have tried
https://github.com/Taeyoung96/Yolo-to-COCO-format-converter
And
Pylabel
They all have a bugs.

I want to train on detectron 2 but it fails to load the dataset because of the wrong json file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瀞厅☆埖开 2025-01-26 23:36:14

您可以使用 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()

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

names_file = Path("/path/to/classes.names")
names = AnnotationSet.parse_names_file(names_file)
annotations.map_labels(names)

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

You can use the globox package (disclaimer: I'm the author). This should ressemble something like:

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()

If you need to map the labels using a .name file:

names_file = Path("/path/to/classes.names")
names = AnnotationSet.parse_names_file(names_file)
annotations.map_labels(names)

you can check the documentation for other formats (Yolo Darknet, Yolo v8, etc.).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文