常见的目标检测bbox标注格式

Pascal VOC

bbox:[x_min, y_min, x_max, y_max]

格式:左上右下

COCO

bbox:[x_min, ymin, width, height]

格式:左上宽高

YOLO

bbox [x_center, y_center, width, height]

并进行数据规范化(normalized)

格式:中心坐标,宽高

YOLO转COCO

python 复制代码
def xywhn2xyxy(x, w=640, h=640, padw=0, padh=0):
    y = x.clone() if isinstance(x, torch.Tensor) else np.copy(x)
    y[:, 0] = w * (x[:, 0] - x[:, 2] / 2) + padw  # top left x
    y[:, 1] = h * (x[:, 1] - x[:, 3] / 2) + padh  # top left y
    y[:, 2] = w * (x[:, 0] + x[:, 2] / 2) + padw  # bottom right x
    y[:, 3] = h * (x[:, 1] + x[:, 3] / 2) + padh  # bottom right y
    return y

COCO 转 YOLO

python 复制代码
 def convert_box(size, box):
        # Convert COCO box to YOLO xywh box
        dw = 1. / size[0]
        dh = 1. / size[1]

        return (box[0] + box[2] / 2) * dw, (box[1] + box[3] / 2) * dh, box[2] * dw, box[3] * dh

Pasic VOC 转 YOLO

python 复制代码
def convert_box(size, box):
        # Convert VOC box to YOLO xywh box
        dw = 1. / size[0]
        dh = 1. / size[1]

        return ((box[0] + box[1]) / 2.0 * dw, (box[2] + box[3]) / 2.0 * dh , (box[1] - box[0]) * dw, (box[3] - box[2]) * * dh)
相关推荐
冬奇Lab10 分钟前
一天一个开源项目(第23篇):PageLM - 开源 AI 教育平台,把学习材料变成互动资源
人工智能·开源
汐汐咯10 分钟前
残差块学习笔记
人工智能
式51611 分钟前
深度学习常见问题
人工智能·深度学习
天竺鼠不该去劝架24 分钟前
RPA 平台选型指南(2026):金智维 vs 来也RPA vs 艺赛旗 vs 阿里云 RPA 深度对比
大数据·数据库·人工智能
aircrushin30 分钟前
具身智能开源生态:小米机器人VLA模型如何推动物理AI产业化?
人工智能·机器人
DN202032 分钟前
AI销售:从不迟到早退,永远秒回,您的忠实员工
人工智能·python
人工智能AI技术40 分钟前
手机就是你的AI实验室:AutoGLM开源实战,用智谱GLM-4.7控制手机完成自动打卡
人工智能
美酒没故事°1 小时前
在扣子平台创建智能体demo
人工智能·ai
MaoziShan1 小时前
CMU Subword Modeling | 09 Lexemes, or What Dictionaries Know about Morphology
开发语言·人工智能·机器学习·语言模型·自然语言处理·c#