欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 家装 > coco数据集转换SAM2格式

coco数据集转换SAM2格式

2026/6/3 4:35:30 来源:https://blog.csdn.net/weixin_44298961/article/details/144379321  浏览:    关键词:coco数据集转换SAM2格式

coco是一个大json汇总了所有train的标签
SAM2训练一张图对应一个json标签

import json
import os
from pycocotools import mask as mask_utils
import numpy as np
import cv2def poly2mask(points, width, height):points_array = np.array(points, dtype=np.int32).reshape(-1, 2)mask = np.zeros((height, width), dtype=np.uint8)  # 注意顺序是(height, width)cv2.fillPoly(mask, [points_array], 255)  # 填充多边形区域为255return mask2rle(mask)def mask2rle(mask):"""将二值化掩码转换为RLE编码"""rle = mask_utils.encode

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com