如何将Yolo片段注释转换为coco格式?

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

我正在尝试将 yolo 段数据集转换为 coco 格式。最初我使用 ultralytics 的 JsonToYolo 从 Coco 转换为 Yolo。现在我想做反之亦然。

我尝试过一些 yolo 到 coco 转换器,例如 YOLO2COCO 并使用 fiftyone 转换器。这些只会将 bbox(边界框)值转换为 coco 格式,而不是分段值。分段值为空([])。

可可格式:

    "annotations": [
        {
            "id": 1,
            "image_id": 1,
            "category_id": 1,
            "segmentation": [
                [
                    5131.4,
                    1099.1,
                    5014.3,
                    1079.0,
                    4918.16,
                    1093.03,
                    4878.82,
                    1161.22,
                    4881.44,
                    1205.81,
                    4898.05,
                    1264.38,
                    4934.77,
                    1283.62,
                    4904.17,
                    1302.85,
                    4982.85,
                    1323.83,
                    4988.97,
                    1338.69,
                    5090.38,
                    1307.22,
                    5135.84,
                    1288.86,
                    5183.05,
                    1283.62,
                    5168.19,
                    1227.67,
                    5179.55,
                    1217.18,
                    5184.8,
                    1199.69,
                    5214.5,
                    1157.7
                ]
            ],
            "area": 62712.0,
            "bbox": [
                4878.82,
                1079.0,
                335.68,
                259.69
            ],
            "iscrowd": 0,
            "attributes": {
                "username": "",
                "occluded": false
            }
        },

Yolo 格式:

0 0.21875 0.380208 0.215625 0.390625 0.215625 0.395833 0.214062 0.401042 0.214062 0.40625 0.2125 0.411458 0.2125 0.427083 0.210938 0.432292 0.210938 0.447917 0.209375 0.453125 0.209375 0.458333 0.207813 0.463542 0.207813 0.46875 0.20625 0.473958 0.20625 0.479167 0.204688 0.484375 0.204688 0.489583 0.203125 0.494792 0.203125 0.515625 0.201562 0.520833 0.201562 0.5625 0.2 0.567708 0.2 0.59375 0.201562 0.598958 0.201562 0.651042 0.203125 0.65625 0.204688 0.651042 0.204688 0.645833 0.20625 0.640625 0.20625 0.635417 0.207813 0.630208 0.207813 0.625 0.209375 0.619792 0.209375 0.614583 0.210938 0.609375 0.210938 0.604167 0.2125 0.598958 0.2125 0.59375 0.214062 0.588542 0.214062 0.578125 0.215625 0.572917 0.215625 0.567708 0.217187 0.5625 0.217187 0.552083 0.21875 0.546875 0.21875 0.536458 0.220313 0.53125 0.220313 0.520833 0.221875 0.515625 0.221875 0.505208 0.223438 0.5 0.223438 0.489583 0.225 0.484375 0.225 0.46875 0.226562 0.463542 0.226562 0.432292 0.228125 0.427083 0.228125 0.380208

另一种方法是使用 Roboflow,其中数据以 yolo 格式上传并以 coco 格式导出。但我需要一个将 yolo 注释转换为 coco 格式的脚本。

有线索吗?

machine-learning deep-learning image-segmentation yolov5 yolonas
1个回答
0
投票

您可以尝试我编写的这个脚本,以当前形式创建一个单一的 .json 文件,用于 COCO 格式的注释。 “https://github.com/claudio9russo7/YolosegmentationtoCocosegmentation”

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