You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

UEA图像标注工具输出格式导入Roboflow可行性及转换方案问询

标注格式适配与转换说明

输出格式与直接上传兼容性

你提到的标注工具及其衍生的django-labeller分支输出的是自定义的JSON标注结构,单张图片对应一份JSON文件,边界框采用「中心点坐标+框宽高」的形式存储。
该格式无法直接上传到Roboflow:Roboflow默认仅支持COCO、VOC、YOLO等通用标注格式,没有内置对该自定义JSON结构的解析逻辑,直接上传会无法识别标注内容。

格式转换方案

目前没有专门的一键转换工具,你可以通过简单的Python脚本完成转换,推荐转为Roboflow适配最好的YOLO TXT格式,转换逻辑如下:

  • 提前读取标注对应图片的总宽高(原JSON文件未存储该参数,需要从原图读取)
  • 将原标注里的中心点坐标、框宽高分别除以图片总宽高做归一化处理
  • 提前建立类别名称到数字ID的映射,按类别ID 归一化中心点x 归一化中心点y 归一化框宽 归一化框高的格式逐行存储标注,保存为和原图同名的txt文件即可。

参考转换代码:

import os
import json
from PIL import Image

# 按需修改以下配置
label_json_folder = "标注JSON文件存放路径"
image_folder = "对应图片存放路径"
output_yolo_folder = "转换后YOLO标注输出路径"
# 按你的实际标注类别填写映射关系,顺序可以自定义
class_to_id = {
    "dog": 0,
    # 补充其他类别
}

os.makedirs(output_yolo_folder, exist_ok=True)

for file_name in os.listdir(label_json_folder):
    if not file_name.endswith("__labels.json"):
        continue
    # 读取原标注
    with open(os.path.join(label_json_folder, file_name), "r", encoding="utf-8") as f:
        raw_label = json.load(f)
    img_name = raw_label["image_filename"]
    # 读取图片尺寸
    img = Image.open(os.path.join(image_folder, img_name))
    img_width, img_height = img.size
    # 生成YOLO格式标注
    yolo_lines = []
    for obj in raw_label["labels"]:
        if obj["label_type"] != "box":
            continue
        cls_id = class_to_id[obj["label_class"]]
        norm_cx = obj["centre"]["x"] / img_width
        norm_cy = obj["centre"]["y"] / img_height
        norm_w = obj["size"]["x"] / img_width
        norm_h = obj["size"]["y"] / img_height
        yolo_lines.append(f"{cls_id} {norm_cx:.6f} {norm_cy:.6f} {norm_w:.6f} {norm_h:.6f}")
    # 保存输出txt
    txt_name = f"{os.path.splitext(img_name)[0]}.txt"
    with open(os.path.join(output_yolo_folder, txt_name), "w", encoding="utf-8") as f:
        f.write("\n".join(yolo_lines))

转换完成后将图片和对应YOLO标注txt放在同一目录下打包,即可正常上传到Roboflow。

内容的提问来源于stack exchange,提问作者Daniel Fitzgerald

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 23:36:02