如果您需要根据已有数据生成TFRecord,则可以先将已有文件转换为PAI标注格式,再生成TFRecord。本文为您介绍标注文件格式。

CSV数据格式如下。
字段 数据类型 描述
数据ID INT 数据标识
原始数据 JSON 包含图片URL
融合答案 JSON 标注结果

图像分类

#数据ID,原始数据,融合答案
1,"{""url"":""http://a.jpg""}","{""option"":""护照""}"
2,"{""url"":""http://b.jpg""}","{""option"":""护照""}"
融合答案字段说明如下。
{
    "option":"护照"    # 图片类别。
}

图像多标签分类

#数据ID,原始数据,融合答案
1,"{""url"":""http://a.jpg""}","{[""option"":""护照"", ""option"":""身份证""]}"
2,"{""url"":""http://b.jpg""}","{[""option"":""护照"", ""option"":""港澳通行证""]}"
融合答案字段说明如下。
{
    "option":["护照", "身份证"]    # 图片标签。
}

物体检测

#数据ID,原始数据,融合答案
1,"{""url"": ""http://b.jpg""}","[{""text"": ""{\""class*\"": \""类别1\""}"", ""coord"": [""306.73"", ""517.59"", ""324.42"", ""282.07"", ""347.69"", ""282.07"", ""333.73"", ""519.45""]}, {""text"": ""{\""class*\"": \""类别2\""}"", ""coord"": [""342.11"", ""723.32"", ""349.56"", ""608.81"", ""366.31"", ""606.95"", ""360.73"", ""730.76""]}]"
2,"{""url"": ""http://a.jpg""}","[{""text"": ""{\""class*\"": \""类别1\""}"", ""coord"": [""338.35"", ""8.53"", ""700.16"", ""8.53"", ""700.16"", ""50.35"", ""338.35"", ""50.35""]}, {""text"": ""{\""class*\"": \""类别2\""}"", ""coord"": [""26.88"", ""64.00"", ""218.03"", ""64.00"", ""218.03"", ""99.84"", ""26.88"", ""99.84""]}]"
融合答案字段说明如下。
[        # 物体列表。
    {
        "text":"{\"class*\": \"类别1\"}",    # 物体类别,JSON字符串。
        "coord":[    # 物体包围盒顶点坐标, x1,y1,x2,y2,x3,y3,x4,y4。
            "338.35",
            "8.53",
            "700.16",
            "8.53",
            "700.16",
            "50.35",
            "338.35",
            "50.35"
        ]
    },
    {
        "text":"{\"class*\": \"类别2\"}",
        "coord":[
            "26.88",
            "64.00",
            "218.03",
            "64.00",
            "218.03",
            "99.84",
            "26.88",
            "99.84"
        ]
    }
]

图像分割

示例下载

#数据ID,原始数据,融合答案
1,"{""http://a.jpg""}","{""ossUrl"":""http://ossgw.alicdn.com/a.png""}"
融合答案字段说明如下。
{
    "ossUrl":"http://ossgw.alicdn.com/a.png"
    # Mask图片地址。Mask图片为PNG格式,第2个通道(0开始)保存类别信息,
    # 取值从0到num_class-1。第一类通常为Background。
}

文字识别

#数据ID,原始数据,融合答案
1,"{""url"": ""http://b.jpg""}","{""text"": ""文本1""}"
2,"{""url"": ""http://a.jpg""}","{""text": ""文本2""}"
融合答案字段说明如下。
{
    "text":"文本1"    # 文字识别内容。
}

文字检测

#数据ID,原始数据,融合答案
1,"{""url"": ""http://b.jpg""}","[[{""text"": ""{\""direction\"": \""底部朝右\"", \""class*\"": \""类别1\""}"", ""coord"": [""306.73"", ""517.59"", ""324.42"", ""282.07"", ""347.69"", ""282.07"", ""333.73"", ""519.45""]}, {""text"": ""{\""direction\"": \""底部朝右\"", \""class*\"": \""类别2\""}"", ""coord"": [""342.11"", ""723.32"", ""349.56"", ""608.81"", ""366.31"", ""606.95"", ""360.73"", ""730.76""]}], {""option"": ""底部朝右""}]"
2,"{""url"": ""http://a.jpg""}","[[{""text"": ""{\""direction\"": \""底部朝下\"", \""class*\"": \""类别1\""}"", ""coord"": [""338.35"", ""8.53"", ""700.16"", ""8.53"", ""700.16"", ""50.35"", ""338.35"", ""50.35""]}, {""text"": ""{\""direction\"": \""底部朝下\"", \""class*\"": \""类别2\""}"", ""coord"": [""26.88"", ""64.00"", ""218.03"", ""64.00"", ""218.03"", ""99.84"", ""26.88"", ""99.84""]}], {""option"": ""底部朝下""}]"
融合答案字段说明如下。
[        # 文字行列表。
    [
        {
            "text":"{\"direction\": \"底部朝下\", \"class*\": \"类别1\"}",
                         # 文字行标注,JSON字符串。其中direction表示文字行朝向,class*表示类别。
            "coord":[ # 文字行包围盒顶点坐标, x1,y1,x2,y2,x3,y3,x4,y4。
                "338.35",
                "8.53",
                "700.16",
                "8.53",
                "700.16",
                "50.35",
                "338.35",
                "50.35"
            ]
        },
        {
            "text":"{\"direction\": \"底部朝下\", \"class*\": \"类别2\"}",
            "coord":[
                "26.88",
                "64.00",
                "218.03",
                "64.00",
                "218.03",
                "99.84",
                "26.88",
                "99.84"
            ]
        }
    ],
    {
        "option":"底部朝下"    # 整体图片朝向。
    }
]
图片朝向分为底部朝下、底部朝上、底部朝左及底部朝右。

端到端的文字识别

#数据ID,原始数据,融合答案
1,"{""url"": ""http://b.jpg""}","[[{""text"": ""{\""text\"": \""文本1\"", \""direction\"": \""底部朝右\"", \""class*\"": \""类别1\""}"", ""coord"": [""306.73"", ""517.59"", ""324.42"", ""282.07"", ""347.69"", ""282.07"", ""333.73"", ""519.45""]}, {""text"": ""{\""text\"": \""文本2\"", \""direction\"": \""底部朝右\"", \""class*\"": \""类别2\""}"", ""coord"": [""342.11"", ""723.32"", ""349.56"", ""608.81"", ""366.31"", ""606.95"", ""360.73"", ""730.76""]}], {""option"": ""底部朝右""}]"
2,"{""url"": ""http://a.jpg""}","[[{""text"": ""{\""text\"": \""文本3\"", \""direction\"": \""底部朝下\"", \""class*\"": \""类别1\""}"", ""coord"": [""338.35"", ""8.53"", ""700.16"", ""8.53"", ""700.16"", ""50.35"", ""338.35"", ""50.35""]}, {""text"": ""{\""text\"": \""文本4\"", \""direction\"": \""底部朝下\"", \""class*\"": \""类别2\""}"", ""coord"": [""26.88"", ""64.00"", ""218.03"", ""64.00"", ""218.03"", ""99.84"", ""26.88"", ""99.84""]}], {""option"": ""底部朝下""}]"
融合答案字段说明如下。
[        # 文字行列表。
    [
        {
            "text":"{\"text\": \"文本3\", "\"direction\": \"底部朝下\", \"class*\": \"类别1\"}",
                         # 文字行标注,JSON字符串。其中direction表示文字行朝向,class*表示类别。                         
            "coord":[ # 文字行包围盒顶点坐标, x1,y1,x2,y2,x3,y3,x4,y4。
                "338.35",
                "8.53",
                "700.16",
                "8.53",
                "700.16",
                "50.35",
                "338.35",
                "50.35"
            ]
        },
        {
            "text":"{\"text\": \"文本4\", \"direction\": \"底部朝下\", \"class*\": \"类别2\"}",
            "coord":[
                "26.88",
                "64.00",
                "218.03",
                "64.00",
                "218.03",
                "99.84",
                "26.88",
                "99.84"
            ]
        }
    ],
    {
        "option":"底部朝下"    # 整体图片朝向。
    }
]
图片朝向分为底部朝下、底部朝上、底部朝左及底部朝右。