常见的目标检测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)
相关推荐
牧子川几秒前
YOLO-AMC:裂缝检测再进化,给 YOLOv11 换上更合适的「注意力」
yolo·目标检测·yolo11·裂缝检测
龙亘川几秒前
数智赋能物业不动产治理:亘川智城智慧物业系统实践解析
大数据·人工智能·智慧城市·开源软件·数据可视化
明月_清风3 分钟前
AI Agent 进入系统层:现在有哪些开源项目在解决这个问题?
人工智能·后端
成为深度学习高手7 分钟前
SEMixer:以随机注意力增强patch语义、渐进混合多尺度的轻量长期时序预测模型
人工智能·深度学习·机器学习·数据挖掘·时间序列
弯_弯17 分钟前
企业 AI 服务商评估:以「是否先做诊断」为第一筛选门
人工智能
归秋14227 分钟前
流行音乐编曲软件怎么选:流行音乐创作的实用工具清单
人工智能
Martina_032129 分钟前
同一片森林换个镜头就忽冷忽暖?用6步统一曝光、LUT与相机后处理
人工智能·游戏·数学建模·3d·自然语言处理·aigc·游戏策划
guslegend31 分钟前
多模态 Agent 如何规划 UI 测试路径
人工智能
网络毒刘31 分钟前
MCP 资源与提示(resources/prompts)实战:不只 tools,把只读上下文结构化喂给 Agent
人工智能·ai·cursor