常见的目标检测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)
相关推荐
正宗咸豆花几秒前
物理AI革命:当算法走出屏幕,制造业如何被重新定义
人工智能·机器人·开源
冬奇Lab11 分钟前
一天一个开源项目(第26篇):ZeroClaw - 零开销、全 Rust 的自主 AI 助手基础设施,与 OpenClaw 的关系与对比
人工智能·开源·资讯
lisw0520 分钟前
组合AI的核心思路与应用!
人工智能·科技·机器学习
绍兴贝贝40 分钟前
代码随想录算法训练营第四十六天|LC647.回文子串|LC516.最长回文子序列|动态规划总结
数据结构·人工智能·python·算法·动态规划·力扣
逐鹿人生2 小时前
【人工智能工程师系列】一【全面Python3.8入门+进阶】ch.3
人工智能
杨浦老苏2 小时前
本地优先的AI个人助手Moltis
人工智能·docker·ai·群晖
OBS插件网2 小时前
OBS直播如何给人脸加口罩特效?OBS口罩特效插件下载安装教程
人工智能·数码相机·语音识别·产品经理
LitchiCheng2 小时前
Mujoco 如何添加 Apriltag 并获得相机视野进行识别
人工智能·python·开源
想用offer打牌2 小时前
一站式了解Agent Skills
人工智能·后端·ai编程
一切尽在,你来2 小时前
LangGraph快速入门
人工智能·python·langchain·ai编程