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

问题描述 投票:0回答:2

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

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

谢谢大家

image deep-learning object-detection data-annotations annotation-processing
2个回答
4
投票

你能尝试一下这个工具吗(免责声明:我是作者)?它(还)不是 Python 包,因此您需要先下载存储库。这应该类似于:

from ObjectDetectionEval import *
from pathlib import Path


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

  annotations = AnnotationSet.from_yolo(gts_path).map_labels(names)
  
  # If you need to change the labels
  # names = Annotation.parse_names_file(names_file)
  # annotations.map_labels(names)

  annotations.save_coco(save_file)


if __name__ == "__main__":
    main()

如果您需要更多控制(坐标格式、图像位置和扩展名等),您应该使用更通用的

AnnotationSet.from_txt()
。如果它不适合您的需求,您可以使用
AnnotationSet.from_folder()
轻松实现您自己的解析器。


0
投票

我收到此错误 globox:错误:无法识别的参数:--image_folder

© www.soinside.com 2019 - 2024. All rights reserved.