Python将COCO格式实例分割数据集转换为YOLO格式实例分割数据集

这篇具有很好参考价值的文章主要介绍了Python将COCO格式实例分割数据集转换为YOLO格式实例分割数据集。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

前言

  • 由于本人水平有限,难免出现错漏,敬请批评改正。
  • 更多精彩内容,可点击进入YOLO系列专栏或我的个人主页查看
  • YOLOv5:添加SE、CBAM、CoordAtt、ECA注意力机制
  • YOLOv5:yolov5s.yaml配置文件解读、增加小目标检测层
  • YOLOv5:IoU、GIoU、DIoU、CIoU、EIoU
  • YOLOv7训练自己的数据集(口罩检测)
  • YOLOv8训练自己的数据集(足球检测)
  • 玩转Jetson Nano(五):TensorRT加速YOLOv5目标检测

相关介绍

  • Python是一种跨平台的计算机程序设计语言。是一个高层次的结合了解释性、编译性、互动性和面向对象的脚本语言。最初被设计用于编写自动化脚本(shell),随着版本的不断更新和语言新功能的添加,越多被用于独立的、大型项目的开发。
  • PyTorch 是一个深度学习框架,封装好了很多网络和深度学习相关的工具方便我们调用,而不用我们一个个去单独写了。它分为 CPU 和 GPU 版本,其他框架还有 TensorFlow、Caffe 等。PyTorch 是由 Facebook 人工智能研究院(FAIR)基于 Torch 推出的,它是一个基于 Python 的可续计算包,提供两个高级功能:1、具有强大的 GPU 加速的张量计算(如 NumPy);2、构建深度神经网络时的自动微分机制。
    Python将COCO格式实例分割数据集转换为YOLO格式实例分割数据集,Python日常小操作,YOLO系列,python,YOLO,开发语言

COCO格式实例分割数据集转换为YOLO格式实例分割数据集

coco格式对应的json文件,以test.json为例

{
    "annotations": [
        {
            "id": 2094,
            "iscrowd": 0,
            "image_id": 173,
            "category_id": 1,
            "segmentation": [
                [
                    1113,
                    777,
                    1115,
                    785,
                    1118,
                    784,
                    1120,
                    786,
                    1120,
                    792,
                    1118,
                    796,
                    1117,
                    801,
                    1117,
                    868,
                    1118,
                    875,
                    1120,
                    880,
                    1124,
                    882,
                    1138,
                    882,
                    1146,
                    884,
                    1153,
                    899,
                    1157,
                    901,
                    1166,
                    901,
                    1176,
                    899,
                    1178,
                    897,
                    1185,
                    888,
                    1204,
                    887,
                    1217,
                    884,
                    1291,
                    886,
                    1299,
                    885,
                    1302,
                    883,
                    1312,
                    883,
                    1323,
                    890,
                    1325,
                    899,
                    1332,
                    905,
                    1353,
                    905,
                    1360,
                    895,
                    1362,
                    885,
                    1364,
                    863,
                    1364,
                    833,
                    1359,
                    797,
                    1351,
                    774,
                    1326,
                    735,
                    1313,
                    726,
                    1297,
                    722,
                    1198,
                    720,
                    1191,
                    716,
                    1186,
                    718,
                    1177,
                    718,
                    1155,
                    732,
                    1150,
                    736,
                    1145,
                    745,
                    1145,
                    747,
                    1140,
                    755,
                    1135,
                    769,
                    1124,
                    776,
                    1121,
                    776,
                    1119,
                    774
                ]
            ],
            "area": 38102,
            "bbox": [
                1113,
                716,
                251,
                189
            ]
        },
        {
            "id": 577,
            "iscrowd": 0,
            "image_id": 43,
            "category_id": 3,
            "segmentation": [
                [
                    950,
                    795,
                    954,
                    803,
                    960,
                    803,
                    961,
                    802,
                    963,
                    801,
                    959,
                    796,
                    957,
                    794,
                    952,
                    794
                ]
            ],
            "area": 76.5,
            "bbox": [
                950,
                794,
                13,
                9
            ]
        },
        {
            "id": 606,
            "iscrowd": 0,
            "image_id": 43,
            "category_id": 3,
            "segmentation": [
                [
                    632,
                    782,
                    628,
                    780,
                    619,
                    780,
                    607,
                    785,
                    601,
                    785,
                    597,
                    786,
                    596,
                    787,
                    594,
                    787,
                    591,
                    790,
                    588,
                    791,
                    581,
                    791,
                    569,
                    797,
                    558,
                    799,
                    552,
                    803,
                    541,
                    804,
                    523,
                    809,
                    515,
                    812,
                    510,
                    815,
                    501,
                    816,
                    495,
                    820,
                    485,
                    821,
                    476,
                    825,
                    470,
                    827,
                    459,
                    829,
                    456,
                    832,
                    447,
                    833,
                    435,
                    840,
                    427,
                    840,
                    420,
                    842,
                    418,
                    844,
                    403,
                    847,
                    398,
                    850,
                    390,
                    851,
                    373,
                    857,
                    368,
                    857,
                    356,
                    862,
                    345,
                    864,
                    327,
                    869,
                    315,
                    874,
                    307,
                    875,
                    297,
                    881,
                    300,
                    883,
                    310,
                    883,
                    318,
                    881,
                    321,
                    879,
                    336,
                    876,
                    341,
                    873,
                    381,
                    860,
                    388,
                    859,
                    410,
                    852,
                    421,
                    847,
                    427,
                    847,
                    434,
                    843,
                    451,
                    838,
                    453,
                    836,
                    460,
                    834,
                    467,
                    834,
                    472,
                    831,
                    492,
                    826,
                    500,
                    822,
                    514,
                    818,
                    524,
                    817,
                    536,
                    811,
                    544,
                    810,
                    550,
                    808,
                    556,
                    804,
                    579,
                    797,
                    583,
                    797,
                    594,
                    792,
                    601,
                    792,
                    609,
                    788,
                    622,
                    786
                ]
            ],
            "area": 1939,
            "bbox": [
                297,
                780,
                335,
                103
            ]
        }
    ],
    "images": [
        {
            "id": 762,
            "width": 1920,
            "height": 1080,
            "file_name": "0762.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 179,
            "width": 1920,
            "height": 1080,
            "file_name": "0179.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 13,
            "width": 1920,
            "height": 1080,
            "file_name": "0013.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1871,
            "width": 1920,
            "height": 1080,
            "file_name": "1871.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 396,
            "width": 1920,
            "height": 1080,
            "file_name": "0396.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1762,
            "width": 1920,
            "height": 1080,
            "file_name": "1762.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 89,
            "width": 1920,
            "height": 1080,
            "file_name": "0089.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 2198,
            "width": 1920,
            "height": 1080,
            "file_name": "2198.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 262,
            "width": 1920,
            "height": 1080,
            "file_name": "0262.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1132,
            "width": 1920,
            "height": 1080,
            "file_name": "1099.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 929,
            "width": 1920,
            "height": 1080,
            "file_name": "0929.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1396,
            "width": 1920,
            "height": 1080,
            "file_name": "1318.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 2208,
            "width": 1920,
            "height": 1080,
            "file_name": "2208.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1248,
            "width": 1920,
            "height": 1080,
            "file_name": "1248.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1909,
            "width": 1920,
            "height": 1080,
            "file_name": "1909.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1487,
            "width": 1920,
            "height": 1080,
            "file_name": "1492.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 341,
            "width": 1920,
            "height": 1080,
            "file_name": "0341.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1851,
            "width": 1920,
            "height": 1080,
            "file_name": "1851.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1742,
            "width": 1920,
            "height": 1080,
            "file_name": "1742.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1957,
            "width": 1920,
            "height": 1080,
            "file_name": "1957.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1418,
            "width": 1920,
            "height": 1080,
            "file_name": "1418.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1592,
            "width": 1920,
            "height": 1080,
            "file_name": "1592.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 19,
            "width": 1920,
            "height": 1080,
            "file_name": "0019.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 579,
            "width": 1920,
            "height": 1080,
            "file_name": "0579.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1407,
            "width": 1920,
            "height": 1080,
            "file_name": "1372.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1975,
            "width": 1920,
            "height": 1080,
            "file_name": "1975.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 931,
            "width": 1920,
            "height": 1080,
            "file_name": "0931.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1977,
            "width": 1920,
            "height": 1080,
            "file_name": "1977.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 40,
            "width": 1920,
            "height": 1080,
            "file_name": "0040.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1366,
            "width": 1920,
            "height": 1080,
            "file_name": "1403.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 889,
            "width": 1920,
            "height": 1080,
            "file_name": "0889.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1050,
            "width": 1920,
            "height": 1080,
            "file_name": "1050.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 669,
            "width": 1920,
            "height": 1080,
            "file_name": "0669.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 2216,
            "width": 1920,
            "height": 1080,
            "file_name": "2216.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 659,
            "width": 1920,
            "height": 1080,
            "file_name": "0659.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 294,
            "width": 1920,
            "height": 1080,
            "file_name": "0294.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1895,
            "width": 1920,
            "height": 1080,
            "file_name": "1895.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 706,
            "width": 1920,
            "height": 1080,
            "file_name": "0710.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1273,
            "width": 1920,
            "height": 1080,
            "file_name": "1273.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 461,
            "width": 1920,
            "height": 1080,
            "file_name": "0461.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1023,
            "width": 1920,
            "height": 1080,
            "file_name": "1023.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1594,
            "width": 1920,
            "height": 1080,
            "file_name": "1594.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1747,
            "width": 1920,
            "height": 1080,
            "file_name": "1747.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1854,
            "width": 1920,
            "height": 1080,
            "file_name": "1854.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 750,
            "width": 1920,
            "height": 1080,
            "file_name": "0750.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1580,
            "width": 1920,
            "height": 1080,
            "file_name": "1580.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1735,
            "width": 1920,
            "height": 1080,
            "file_name": "1735.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1504,
            "width": 1920,
            "height": 1080,
            "file_name": "1509.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1630,
            "width": 1920,
            "height": 1080,
            "file_name": "1630.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 629,
            "width": 1920,
            "height": 1080,
            "file_name": "0629.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 367,
            "width": 1920,
            "height": 1080,
            "file_name": "0367.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1833,
            "width": 1920,
            "height": 1080,
            "file_name": "1833.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 583,
            "width": 1920,
            "height": 1080,
            "file_name": "0583.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 178,
            "width": 1920,
            "height": 1080,
            "file_name": "0178.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 199,
            "width": 1920,
            "height": 1080,
            "file_name": "0199.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1836,
            "width": 1920,
            "height": 1080,
            "file_name": "1836.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1636,
            "width": 1920,
            "height": 1080,
            "file_name": "1636.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 382,
            "width": 1920,
            "height": 1080,
            "file_name": "0382.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 421,
            "width": 1920,
            "height": 1080,
            "file_name": "0421.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1296,
            "width": 1920,
            "height": 1080,
            "file_name": "1328.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 2054,
            "width": 1920,
            "height": 1080,
            "file_name": "2054.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1072,
            "width": 1920,
            "height": 1080,
            "file_name": "1095.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 601,
            "width": 1920,
            "height": 1080,
            "file_name": "0601.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1313,
            "width": 1920,
            "height": 1080,
            "file_name": "1345.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 726,
            "width": 1920,
            "height": 1080,
            "file_name": "0704.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 924,
            "width": 1920,
            "height": 1080,
            "file_name": "0924.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 139,
            "width": 1920,
            "height": 1080,
            "file_name": "0139.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 445,
            "width": 1920,
            "height": 1080,
            "file_name": "0445.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1436,
            "width": 1920,
            "height": 1080,
            "file_name": "1441.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 1835,
            "width": 1920,
            "height": 1080,
            "file_name": "1835.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 311,
            "width": 1920,
            "height": 1080,
            "file_name": "0311.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        
        {
            "id": 173,
            "width": 1920,
            "height": 1080,
            "file_name": "0173.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        },
        {
            "id": 43,
            "width": 1920,
            "height": 1080,
            "file_name": "0043.jpg",
            "license": "",
            "flickr_url": "",
            "coco_url": "",
            "date_captured": ""
        }
    ],
    "categories": [
        {
            "id": 1,
            "name": "car",
            "color": [
                52,
                101,
                164
            ],
            "supercategory": ""
        },
        {
            "id": 2,
            "name": "traffic_sign",
            "color": [
                245,
                128,
                6
            ],
            "supercategory": ""
        },
        {
            "id": 3,
            "name": "lane_lines",
            "color": [
                115,
                210,
                22
            ],
            "supercategory": ""
        },
        {
            "id": 4,
            "name": "person",
            "color": [
                239,
                41,
                41
            ],
            "supercategory": ""
        },
        {
            "id": 5,
            "name": "motorcyclist",
            "color": [
                145,
                104,
                190
            ],
            "supercategory": ""
        },
        {
            "id": 6,
            "name": "cyclist",
            "color": [
                239,
                41,
                41
            ],
            "supercategory": ""
        }
    ]
}

格式转换代码,内容如下

import os
import json
import shutil

def write_yolo_txt_file(txt_file_path,label_seg_x_y_list):
    if not os.path.exists(txt_file_path):
        with open(txt_file_path, "w") as file:
            for element in label_seg_x_y_list:
                file.write(str(element) + " ")
            file.write('\n')
    else:
        with open(txt_file_path, "a") as file:
            for element in label_seg_x_y_list:
                file.write(str(element) + " ")
            file.write('\n')

def read_json(in_json_path,img_dir,target_dir):
    with open(in_json_path, "r", encoding='utf-8') as f:
        # json.load数据到变量json_data
        json_data = json.load(f) 

    # print(len(json_data['annotations']))
    # print(len(json_data['images']))
    # print(len(json_data['categories']))

    for annotation in json_data['annotations']: # 遍历标注数据信息
        # print(annotation)
        category_id = annotation['category_id']
        image_id = annotation['image_id']
        for image in json_data['images']: # 遍历图片相关信息
            if image['id'] == image_id:
                width = image['width'] # 图片宽
                height = image['height'] # 图片高
                img_file_name = image['file_name'] # 图片名称
                txt_file_name = image['file_name'].split('.')[0] + '.txt' # 要保存的对应txt文件名
                break
        # print(width,height,img_file_name,txt_file_name)
        segmentation = annotation['segmentation'] # 图像分割点信息[[x1,y1,x2,y2,...,xn,yn]]
        seg_x_y_list = [i/width if num%2==0 else i/height for num,i in enumerate(segmentation[0])] # 归一化图像分割点信息
        label_seg_x_y_list = seg_x_y_list[:]
        label_seg_x_y_list.insert(0,category_id) # 图像类别与分割点信息[label,x1,y1,x2,y2,...,xn,yn]
        # print(label_seg_x_y_list)

        # 写txt文件
        txt_file_path = target_dir + txt_file_name
        # print(txt_file_path)
        write_yolo_txt_file(txt_file_path,label_seg_x_y_list)

        # 选出txt对应img文件
        img_file_path = img_dir + img_file_name
        # print(img_file_path)
        shutil.copy(img_file_path,target_dir)



if __name__=="__main__":
    img_dir = 'JPEGImages/'
    target_dir = 'testset/'
    if not os.path.exists(target_dir):
        os.mkdir(target_dir)
    in_json_path = './test.json'
    read_json(in_json_path,img_dir,target_dir)

Python将COCO格式实例分割数据集转换为YOLO格式实例分割数据集,Python日常小操作,YOLO系列,python,YOLO,开发语言Python将COCO格式实例分割数据集转换为YOLO格式实例分割数据集,Python日常小操作,YOLO系列,python,YOLO,开发语言文章来源地址https://www.toymoban.com/news/detail-614381.html

  • 由于本人水平有限,难免出现错漏,敬请批评改正。
  • 更多精彩内容,可点击进入YOLO系列专栏或我的个人主页查看
  • YOLOv5:添加SE、CBAM、CoordAtt、ECA注意力机制
  • YOLOv5:yolov5s.yaml配置文件解读、增加小目标检测层
  • YOLOv5:IoU、GIoU、DIoU、CIoU、EIoU
  • YOLOv7训练自己的数据集(口罩检测)
  • YOLOv8训练自己的数据集(足球检测)
  • 玩转Jetson Nano(五):TensorRT加速YOLOv5目标检测

到了这里,关于Python将COCO格式实例分割数据集转换为YOLO格式实例分割数据集的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 目标检测任务中常用的数据集格式(voc、coco、yolo)

    VOC数据集(Annotation的格式是xmI) Pascal VOC数据集是目标检测的常用的大规模数据集之一,从05年到12年都会举办比赛,比赛任务task: 分类Classification 目标检测Object Detection 语义分割Class Segmentation 实例分割Object Segmentation Action Classification(专注于人体动作的一种分类) Person Layout(

    2024年02月14日
    浏览(49)
  • 代码实现如何将yolov5数据格式转换为coco格式

    很多训练算法使用coco格式,而原版的数据集可能采用yolov5的数据格式,故写个简单的教程; yolov5数据集的目录格式:  images存放的图像,例如 1.jpg,2.jpg. labels存放的是对应图片的标注信息,例如 1.txt,2.txt. txt 中信息是这样的: (框高)每一行对应一个bbox框信息,分别是cla

    2024年02月12日
    浏览(40)
  • segmentation后 mask图片数据转换成coco对应的json格式

    segmentation后 mask二值图片数据转换成coco对应的json格式 转出来之后的json数据中segmentation部分会有一些问题,它不是一个1 * n维度的数据 而是包含了很多段,需要合并 如图: 合并之前: 合并之后,所有的边缘点在一个list中: 最终转好的格式如下图: 合并代码:

    2024年02月12日
    浏览(38)
  • 使用LabelMe标注目标检测数据集并转换为COCO2017格式

    当你安装好labelme启动后,open dir开始标注,选择Create Rectangle 拖拽画框,然后选择类别(没有就直接输入会自动新建),标注好一幅图后点击next image会弹框提示保存json文件,保存即可。 当你将所有图像标注完后,点击Next Image是没有反应的(因为没有Next图了),此时直接x掉

    2024年02月11日
    浏览(49)
  • COCO2017标注文件格式和YOLO标注文件格式的解析

    声明:本篇博客内容是作者在制作数据集时的一些记录,引用了一些博客的内容,并结合个人理解进行了归纳,引用出处在“参考内容”章节,若有侵权,请联系作者删除。若有纰漏和错误,敬请指正! 1、COCO2017数据集的标注格式及含义 COCO 的全称是Common Objects in COntext,是

    2024年02月08日
    浏览(46)
  • 将YOLO数据集转成COCO格式,单个文件夹转为单个json文件,例如.../images/train转为instance_train.json

    参考链接 :objectdetection-tricks/tricks_4.py 相关视频教学:tricks_4 用于yolov5和v7中的yolo格式转换coco格式的脚本.(如何在v5和v7中输出ap_small,ap_middle,ap_large coco指标) 还可以参考相关的VOC转COCO的方式:damo-yolo/voc2coco.py 代码效果 :将数据集转成COCO格式, 单个文件夹 转为 单个json 文件

    2024年02月01日
    浏览(46)
  • 数据格式转换(labelme、labelimg、yolo格式相互转换)

    👨‍💻 个人简介: 深度学习图像领域工作者 🎉 总结链接:              链接中主要是个人工作的总结,每个链接都是一些常用demo,代码直接复制运行即可。包括:                     📌 1.工作中常用深度学习脚本                     📌 2.to

    2023年04月23日
    浏览(49)
  • 一键转换labelimg格式为COCO格式

    1.实现了将目标检测任务中使用的 Pascal VOC 格式标注数据转换为 COCO 格式标注数据,并生成两个 COCO 格式的 JSON 文件,用于训练和验证。 2.通过解析 XML 文件,提取图片信息、类别信息和目标框信息,并将这些数据添加到对应的 COCO 格式数据中。 3.使用随机数种子将数据按照

    2024年02月14日
    浏览(43)
  • YOLO格式数据集(.txt)如何转换为VOC格式数据集(.xml)

    前言: 安装好python环境与编译器 转换: 将标注文件从文本格式( .txt )转换为 XML 格式( .xml )可以通过以下步骤完成: 解析文本标注文件:打开 .txt 文件,逐行读取每个标注,并解析边界框坐标和类别信息。 创建 XML 文件:使用 Python 的内置库 xml.etree.ElementTree 创建一个

    2024年02月12日
    浏览(47)
  • 目标检测数据集格式转换:将labelme格式转为YOLO以及VOC格式

    一个目标检测项目需要自己找图片标注数据进行训练,训练需要YOLO格式,但数据增广需要VOC格式,该文记录如何将labelme标注的数据格式转为YOLO格式,再从YOLO格式转为VOC格式,只作为自己用的记录,如果你刚好也需要这么干,或者需要文中提到的某一种转换,也可以参考一下

    2024年02月08日
    浏览(53)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包