Template Service Prediction supports two types: Custom KV Template and Custom Table Template.
Try it now
Test
RAM authorization
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| TaskId |
integer |
Yes |
The task ID. |
1 |
| Content |
string |
No |
The URL of the image or PDF file. You must specify either the |
https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/demo.png |
| BinaryToText |
boolean |
No |
Specifies the input format. If this parameter is set to |
false:表示content传入的是url true:表示body是直接传入图片进行base64的内容 |
| Body |
string |
No |
The base64-encoded content of the image. This parameter is mutually exclusive with Content. |
data:image/png;base64,xxxxx |
You must specify either the Content or Body field. To provide an image URL, use the Content field. To provide base64-encoded data, use the Body field and set BinaryToText to true.
PDF files are limited to 20 MB and 10 pages. Unlike predictions from long-document models, all other prediction services process only the first page of a document.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response schema. |
||
| RequestId |
string |
The unique ID for the request. |
F25FBAB4-665A-5D85-8AEF-39AE29F7D588 |
| Data |
object |
The returned data. |
{ "score": 0.9091, "data": [ { "prob": 1, "fieldName": "姓名", "fieldWordRaw": "方大呆", "wordInfo": [ { "prob": 0.9899999999999999, "location": [ { "x": 119, "y": 48 }, { "x": 199, "y": 48 }, { "x": 199, "y": 69 }, { "x": 119, "y": 69 } ], "word": "方大呆", "charInfo": [ { "prob": 0.99, "location": [ { "x": 119, "y": 48 }, { "x": 142, "y": 48 }, { "x": 142, "y": 67 }, { "x": 119, "y": 67 } ], "word": "方" }, { "prob": 0.99, "location": [ { "x": 142, "y": 48 }, { "x": 165, "y": 48 }, { "x": 165, "y": 67 }, { "x": 142, "y": 67 } ], "word": "大" }, { "prob": 0.99, "location": [ { "x": 167, "y": 48 }, { "x": 197, "y": 48 }, { "x": 197, "y": 67 }, { "x": 167, "y": 67 } ], "word": "呆" } ] } ], "location": [ { "x": 119, "y": 48 }, { "x": 199, "y": 48 }, { "x": 199, "y": 69 }, { "x": 119, "y": 69 } ], "fieldWord": "方大呆" }, { "prob": 1, "fieldName": "性别", "fieldWordRaw": "男", "wordInfo": [ { "prob": 0.99, "location": [ { "x": 117, "y": 93 }, { "x": 142, "y": 93 }, { "x": 142, "y": 112 }, { "x": 117, "y": 112 } ], "word": "男", "charInfo": [ { "prob": 0.99, "location": [ { "x": 117, "y": 93 }, { "x": 142, "y": 93 }, { "x": 142, "y": 112 }, { "x": 117, "y": 112 } ], "word": "男" } ] } ], "location": [ { "x": 117, "y": 93 }, { "x": 142, "y": 93 }, { "x": 142, "y": 112 }, { "x": 117, "y": 112 } ], "fieldWord": "男" }, { "prob": 1, "fieldName": "身份证号", "fieldWordRaw": "310101********3222", "wordInfo": [ { "prob": 0.9899999999999998, "location": [ { "x": 206, "y": 301 }, { "x": 518, "y": 301 }, { "x": 518, "y": 320 }, { "x": 206, "y": 320 } ], "word": "310101198610203222", "charInfo": [ { "prob": 0.99, "location": [ { "x": 206, "y": 302 }, { "x": 223, "y": 302 }, { "x": 223, "y": 319 }, { "x": 206, "y": 319 } ], "word": "3" }, { "prob": 0.99, "location": [ { "x": 223, "y": 302 }, { "x": 238, "y": 302 }, { "x": 238, "y": 319 }, { "x": 223, "y": 319 } ], "word": "1" }, { "prob": 0.99, "location": [ { "x": 240, "y": 302 }, { "x": 255, "y": 302 }, { "x": 255, "y": 319 }, { "x": 240, "y": 319 } ], "word": "0" }, { "prob": 0.99, "location": [ { "x": 259, "y": 302 }, { "x": 274, "y": 302 }, { "x": 274, "y": 319 }, { "x": 259, "y": 319 } ], "word": "1" }, { "prob": 0.99, "location": [ { "x": 276, "y": 302 }, { "x": 291, "y": 302 }, { "x": 291, "y": 319 }, { "x": 276, "y": 319 } ], "word": "0" }, { "prob": 0.99, "location": [ { "x": 292, "y": 302 }, { "x": 307, "y": 302 }, { "x": 307, "y": 319 }, { "x": 292, "y": 319 } ], "word": "1" }, { "prob": 0.99, "location": [ { "x": 311, "y": 302 }, { "x": 326, "y": 302 }, { "x": 326, "y": 319 }, { "x": 311, "y": 319 } ], "word": "1" }, { "prob": 0.99, "location": [ { "x": 328, "y": 302 }, { "x": 343, "y": 302 }, { "x": 343, "y": 319 }, { "x": 328, "y": 319 } ], "word": "9" }, { "prob": 0.99, "location": [ { "x": 344, "y": 302 }, { "x": 359, "y": 302 }, { "x": 359, "y": 319 }, { "x": 344, "y": 319 } ], "word": "8" }, { "prob": 0.99, "location": [ { "x": 361, "y": 302 }, { "x": 376, "y": 302 }, { "x": 376, "y": 319 }, { "x": 361, "y": 319 } ], "word": "6" }, { "prob": 0.99, "location": [ { "x": 380, "y": 302 }, { "x": 395, "y": 302 }, { "x": 395, "y": 319 }, { "x": 380, "y": 319 } ], "word": "1" }, { "prob": 0.99, "location": [ { "x": 396, "y": 302 }, { "x": 411, "y": 302 }, { "x": 411, "y": 319 }, { "x": 396, "y": 319 } ], "word": "0" }, { "prob": 0.99, "location": [ { "x": 415, "y": 302 }, { "x": 430, "y": 302 }, { "x": 430, "y": 319 }, { "x": 415, "y": 319 } ], "word": "2" }, { "prob": 0.99, "location": [ { "x": 432, "y": 302 }, { "x": 447, "y": 302 }, { "x": 447, "y": 319 }, { "x": 432, "y": 319 } ], "word": "0" }, { "prob": 0.99, "location": [ { "x": 448, "y": 302 }, { "x": 463, "y": 302 }, { "x": 463, "y": 319 }, { "x": 448, "y": 319 } ], "word": "3" }, { "prob": 0.99, "location": [ { "x": 467, "y": 302 }, { "x": 482, "y": 302 }, { "x": 482, "y": 319 }, { "x": 467, "y": 319 } ], "word": "2" }, { "prob": 0.99, "location": [ { "x": 484, "y": 302 }, { "x": 499, "y": 302 }, { "x": 499, "y": 319 }, { "x": 484, "y": 319 } ], "word": "2" }, { "prob": 0.99, "location": [ { "x": 501, "y": 302 }, { "x": 516, "y": 302 }, { "x": 516, "y": 319 }, { "x": 501, "y": 319 } ], "word": "2" } ] } ], "location": [ { "x": 206, "y": 301 }, { "x": 518, "y": 301 }, { "x": 518, "y": 320 }, { "x": 206, "y": 320 } ], "fieldWord": "310101198610203222" }, { "prob": 1, "fieldName": "名族", "fieldWordRaw": "汉", "wordInfo": [ { "prob": 0.99, "location": [ { "x": 232, "y": 94 }, { "x": 259, "y": 94 }, { "x": 259, "y": 112 }, { "x": 232, "y": 112 } ], "word": "汉", "charInfo": [ { "prob": 0.99, "location": [ { "x": 232, "y": 94 }, { "x": 259, "y": 94 }, { "x": 259, "y": 112 }, { "x": 232, "y": 112 } ], "word": "汉" } ] } ], "location": [ { "x": 232, "y": 94 }, { "x": 259, "y": 94 }, { "x": 259, "y": 112 }, { "x": 232, "y": 112 } ], "fieldWord": "汉" } ], "specificType": "infoCustomeKvTemp", "width": 586, "angle": 0, "classType": "template", "height": 374, "predictFile": "https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/demo.png" } |
| Message |
string |
The response message. |
successful |
| Code |
string |
The status code. A value of |
200 |
Fields in the Data object of the template service prediction API response:
score The confidence score for the entire prediction, ranging from 0 to 1.
data An array of prediction results from the algorithm.
prob The confidence score for an individual algorithm result, ranging from 0 to 1.
fieldName The key of the extracted key-value pair.
fieldWord The value of the extracted key-value pair.
location The coordinates of the extracted result. For example, `{ "x": 119, "y": 48 }` represents a point on the page.
wordInfo Detailed information about the extracted content, including the location information for each character.
specificType The type of algorithm used. Possible values are:
- `infoCustomeKvTemp`: custom KV template.
- `infoCustomeTableTemp`: custom table template.
- `ocr_infoExtractBill`: information extraction with OCR.
- `infoExtractBill`: form/receipt extraction.
- `infoExtractDoc`: long document extraction.
classType The type of prediction service. Possible values are `model prediction service` and `template service`.
predictFile The URL of the prediction file. This URL expires in 60 minutes.
Examples
Success response
JSON format
{
"RequestId": "F25FBAB4-665A-5D85-8AEF-39AE29F7D588",
"Data": {
"score": 0.9091,
"data": [
{
"prob": 1,
"fieldName": "姓名",
"fieldWordRaw": "方大呆",
"wordInfo": [
{
"prob": 0.9899999999999999,
"location": [
{
"x": 119,
"y": 48
},
{
"x": 199,
"y": 48
},
{
"x": 199,
"y": 69
},
{
"x": 119,
"y": 69
}
],
"word": "方大呆",
"charInfo": [
{
"prob": 0.99,
"location": [
{
"x": 119,
"y": 48
},
{
"x": 142,
"y": 48
},
{
"x": 142,
"y": 67
},
{
"x": 119,
"y": 67
}
],
"word": "方"
},
{
"prob": 0.99,
"location": [
{
"x": 142,
"y": 48
},
{
"x": 165,
"y": 48
},
{
"x": 165,
"y": 67
},
{
"x": 142,
"y": 67
}
],
"word": "大"
},
{
"prob": 0.99,
"location": [
{
"x": 167,
"y": 48
},
{
"x": 197,
"y": 48
},
{
"x": 197,
"y": 67
},
{
"x": 167,
"y": 67
}
],
"word": "呆"
}
]
}
],
"location": [
{
"x": 119,
"y": 48
},
{
"x": 199,
"y": 48
},
{
"x": 199,
"y": 69
},
{
"x": 119,
"y": 69
}
],
"fieldWord": "方大呆"
},
{
"prob": 1,
"fieldName": "性别",
"fieldWordRaw": "男",
"wordInfo": [
{
"prob": 0.99,
"location": [
{
"x": 117,
"y": 93
},
{
"x": 142,
"y": 93
},
{
"x": 142,
"y": 112
},
{
"x": 117,
"y": 112
}
],
"word": "男",
"charInfo": [
{
"prob": 0.99,
"location": [
{
"x": 117,
"y": 93
},
{
"x": 142,
"y": 93
},
{
"x": 142,
"y": 112
},
{
"x": 117,
"y": 112
}
],
"word": "男"
}
]
}
],
"location": [
{
"x": 117,
"y": 93
},
{
"x": 142,
"y": 93
},
{
"x": 142,
"y": 112
},
{
"x": 117,
"y": 112
}
],
"fieldWord": "男"
},
{
"prob": 1,
"fieldName": "身份证号",
"fieldWordRaw": "310101********3222",
"wordInfo": [
{
"prob": 0.9899999999999998,
"location": [
{
"x": 206,
"y": 301
},
{
"x": 518,
"y": 301
},
{
"x": 518,
"y": 320
},
{
"x": 206,
"y": 320
}
],
"word": "310101198610203222",
"charInfo": [
{
"prob": 0.99,
"location": [
{
"x": 206,
"y": 302
},
{
"x": 223,
"y": 302
},
{
"x": 223,
"y": 319
},
{
"x": 206,
"y": 319
}
],
"word": "3"
},
{
"prob": 0.99,
"location": [
{
"x": 223,
"y": 302
},
{
"x": 238,
"y": 302
},
{
"x": 238,
"y": 319
},
{
"x": 223,
"y": 319
}
],
"word": "1"
},
{
"prob": 0.99,
"location": [
{
"x": 240,
"y": 302
},
{
"x": 255,
"y": 302
},
{
"x": 255,
"y": 319
},
{
"x": 240,
"y": 319
}
],
"word": "0"
},
{
"prob": 0.99,
"location": [
{
"x": 259,
"y": 302
},
{
"x": 274,
"y": 302
},
{
"x": 274,
"y": 319
},
{
"x": 259,
"y": 319
}
],
"word": "1"
},
{
"prob": 0.99,
"location": [
{
"x": 276,
"y": 302
},
{
"x": 291,
"y": 302
},
{
"x": 291,
"y": 319
},
{
"x": 276,
"y": 319
}
],
"word": "0"
},
{
"prob": 0.99,
"location": [
{
"x": 292,
"y": 302
},
{
"x": 307,
"y": 302
},
{
"x": 307,
"y": 319
},
{
"x": 292,
"y": 319
}
],
"word": "1"
},
{
"prob": 0.99,
"location": [
{
"x": 311,
"y": 302
},
{
"x": 326,
"y": 302
},
{
"x": 326,
"y": 319
},
{
"x": 311,
"y": 319
}
],
"word": "1"
},
{
"prob": 0.99,
"location": [
{
"x": 328,
"y": 302
},
{
"x": 343,
"y": 302
},
{
"x": 343,
"y": 319
},
{
"x": 328,
"y": 319
}
],
"word": "9"
},
{
"prob": 0.99,
"location": [
{
"x": 344,
"y": 302
},
{
"x": 359,
"y": 302
},
{
"x": 359,
"y": 319
},
{
"x": 344,
"y": 319
}
],
"word": "8"
},
{
"prob": 0.99,
"location": [
{
"x": 361,
"y": 302
},
{
"x": 376,
"y": 302
},
{
"x": 376,
"y": 319
},
{
"x": 361,
"y": 319
}
],
"word": "6"
},
{
"prob": 0.99,
"location": [
{
"x": 380,
"y": 302
},
{
"x": 395,
"y": 302
},
{
"x": 395,
"y": 319
},
{
"x": 380,
"y": 319
}
],
"word": "1"
},
{
"prob": 0.99,
"location": [
{
"x": 396,
"y": 302
},
{
"x": 411,
"y": 302
},
{
"x": 411,
"y": 319
},
{
"x": 396,
"y": 319
}
],
"word": "0"
},
{
"prob": 0.99,
"location": [
{
"x": 415,
"y": 302
},
{
"x": 430,
"y": 302
},
{
"x": 430,
"y": 319
},
{
"x": 415,
"y": 319
}
],
"word": "2"
},
{
"prob": 0.99,
"location": [
{
"x": 432,
"y": 302
},
{
"x": 447,
"y": 302
},
{
"x": 447,
"y": 319
},
{
"x": 432,
"y": 319
}
],
"word": "0"
},
{
"prob": 0.99,
"location": [
{
"x": 448,
"y": 302
},
{
"x": 463,
"y": 302
},
{
"x": 463,
"y": 319
},
{
"x": 448,
"y": 319
}
],
"word": "3"
},
{
"prob": 0.99,
"location": [
{
"x": 467,
"y": 302
},
{
"x": 482,
"y": 302
},
{
"x": 482,
"y": 319
},
{
"x": 467,
"y": 319
}
],
"word": "2"
},
{
"prob": 0.99,
"location": [
{
"x": 484,
"y": 302
},
{
"x": 499,
"y": 302
},
{
"x": 499,
"y": 319
},
{
"x": 484,
"y": 319
}
],
"word": "2"
},
{
"prob": 0.99,
"location": [
{
"x": 501,
"y": 302
},
{
"x": 516,
"y": 302
},
{
"x": 516,
"y": 319
},
{
"x": 501,
"y": 319
}
],
"word": "2"
}
]
}
],
"location": [
{
"x": 206,
"y": 301
},
{
"x": 518,
"y": 301
},
{
"x": 518,
"y": 320
},
{
"x": 206,
"y": 320
}
],
"fieldWord": "310101198610203222"
},
{
"prob": 1,
"fieldName": "名族",
"fieldWordRaw": "汉",
"wordInfo": [
{
"prob": 0.99,
"location": [
{
"x": 232,
"y": 94
},
{
"x": 259,
"y": 94
},
{
"x": 259,
"y": 112
},
{
"x": 232,
"y": 112
}
],
"word": "汉",
"charInfo": [
{
"prob": 0.99,
"location": [
{
"x": 232,
"y": 94
},
{
"x": 259,
"y": 94
},
{
"x": 259,
"y": 112
},
{
"x": 232,
"y": 112
}
],
"word": "汉"
}
]
}
],
"location": [
{
"x": 232,
"y": 94
},
{
"x": 259,
"y": 94
},
{
"x": 259,
"y": 112
},
{
"x": 232,
"y": 112
}
],
"fieldWord": "汉"
}
],
"specificType": "infoCustomeKvTemp",
"width": 586,
"angle": 0,
"classType": "template",
"height": 374,
"predictFile": "https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/demo.png"
},
"Message": "successful",
"Code": "200"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 200 | 21002 | 模板预测超时 | |
| 200 | 21003 | 模板预测失败 | |
| 200 | 21004 | 模板提交失败 | |
| 200 | 10001 | 参数出错 | |
| 200 | 10005 | 服务不存在 | |
| 200 | 21018 | 未找到模板信息 | |
| 200 | 16001 | 未找到可预测的模型 | |
| 200 | 16004 | 指定的模型不存在 | |
| 200 | 23002 | 获取资源HTTP异常 | |
| 200 | 22002 | ocr服务异常 | |
| 200 | 11002 | 账号没有开通服务 | |
| 200 | 19999 | 未知异常 |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.