PredictTemplateModel
Performs template-based prediction, which currently includes two types: custom KV templates and custom table templates.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
documentautoml:PredictTemplateModel |
get |
*All Resource
|
None | None |
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. |
https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/demo.png |
| BinaryToText |
boolean |
No |
Set to false when the Content field contains an image URL. Set to true when the Body field contains Base64-encoded content. |
false: The Content field contains a URL. true: The Body field contains Base64-encoded image content |
| Body |
string |
No |
The Base64 encoding content of the image. |
data:image/png;base64,xxxxx |
Specify either the Content field or the Body field. If the input is an image URL, set Content to the image access address. If the input is Base64 encoding content, set the Body field and set BinaryToText to true.
PDF files are limited to 20 MB and 10 pages. Except for long-document model predictions, all other prediction services process only the first page.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Schema of Response |
||
| RequestId |
string |
Id of the request |
F25FBAB4-665A-5D85-8AEF-39AE29F7D588 |
| Data |
object |
The response data. |
{ "score": 0.9091, "data": [ { "prob": 1, "fieldName": "Name", "fieldWordRaw": "John Smith", "wordInfo": [ { "prob": 0.9899999999999999, "location": [ { "x": 119, "y": 48 }, { "x": 199, "y": 48 }, { "x": 199, "y": 69 }, { "x": 119, "y": 69 } ], "word": "John Smith", "charInfo": [ { "prob": 0.99, "location": [ { "x": 119, "y": 48 }, { "x": 142, "y": 48 }, { "x": 142, "y": 67 }, { "x": 119, "y": 67 } ], "word": "J" }, { "prob": 0.99, "location": [ { "x": 142, "y": 48 }, { "x": 165, "y": 48 }, { "x": 165, "y": 67 }, { "x": 142, "y": 67 } ], "word": "o" }, { "prob": 0.99, "location": [ { "x": 167, "y": 48 }, { "x": 197, "y": 48 }, { "x": 197, "y": 67 }, { "x": 167, "y": 67 } ], "word": "h" } ] } ], "location": [ { "x": 119, "y": 48 }, { "x": 199, "y": 48 }, { "x": 199, "y": 69 }, { "x": 119, "y": 69 } ], "fieldWord": "John Smith" }, { "prob": 1, "fieldName": "Gender", "fieldWordRaw": "Male", "wordInfo": [ { "prob": 0.99, "location": [ { "x": 117, "y": 93 }, { "x": 142, "y": 93 }, { "x": 142, "y": 112 }, { "x": 117, "y": 112 } ], "word": "Male", "charInfo": [ { "prob": 0.99, "location": [ { "x": 117, "y": 93 }, { "x": 142, "y": 93 }, { "x": 142, "y": 112 }, { "x": 117, "y": 112 } ], "word": "Male" } ] } ], "location": [ { "x": 117, "y": 93 }, { "x": 142, "y": 93 }, { "x": 142, "y": 112 }, { "x": 117, "y": 112 } ], "fieldWord": "Male" }, { "prob": 1, "fieldName": "ID Number", "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": "Ethnicity", "fieldWordRaw": "Han", "wordInfo": [ { "prob": 0.99, "location": [ { "x": 232, "y": 94 }, { "x": 259, "y": 94 }, { "x": 259, "y": 112 }, { "x": 232, "y": 112 } ], "word": "Han", "charInfo": [ { "prob": 0.99, "location": [ { "x": 232, "y": 94 }, { "x": 259, "y": 94 }, { "x": 259, "y": 112 }, { "x": 232, "y": 112 } ], "word": "Han" } ] } ], "location": [ { "x": 232, "y": 94 }, { "x": 259, "y": 94 }, { "x": 259, "y": 112 }, { "x": 232, "y": 112 } ], "fieldWord": "Han" } ], "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 indicates success. |
200 |
Description of the Data field returned by the template service prediction API:
score Confidence score of the prediction service, ranging from 0 to 1.
data Prediction results returned by the algorithm, in array format.
prob Confidence score of the algorithm result, ranging from 0 to 1.
fieldName Extracted key.
fieldWord Extracted value.
location Coordinate position of the extracted result. {"x": 119, "y": 48} represents a coordinate point on the page.
wordInfo Detailed information about the extracted content, including position information for each character.
specificType Algorithm type (infoCustomeKvTemp: custom KV template, infoCustomeTableTemp: custom table template, ocr_infoExtractBill: information extraction OCR recognition, infoExtractBill: document and receipt extraction, infoExtractDoc: long-document information extraction).
classType Model prediction service or template prediction service.
predictFile URL of the prediction file (expires after 60 minutes).
Examples
Success response
JSON format
{
"RequestId": "F25FBAB4-665A-5D85-8AEF-39AE29F7D588",
"Data": {
"score": 0.9091,
"data": [
{
"prob": 1,
"fieldName": "Name",
"fieldWordRaw": "John Smith",
"wordInfo": [
{
"prob": 0.9899999999999999,
"location": [
{
"x": 119,
"y": 48
},
{
"x": 199,
"y": 48
},
{
"x": 199,
"y": 69
},
{
"x": 119,
"y": 69
}
],
"word": "John Smith",
"charInfo": [
{
"prob": 0.99,
"location": [
{
"x": 119,
"y": 48
},
{
"x": 142,
"y": 48
},
{
"x": 142,
"y": 67
},
{
"x": 119,
"y": 67
}
],
"word": "J"
},
{
"prob": 0.99,
"location": [
{
"x": 142,
"y": 48
},
{
"x": 165,
"y": 48
},
{
"x": 165,
"y": 67
},
{
"x": 142,
"y": 67
}
],
"word": "o"
},
{
"prob": 0.99,
"location": [
{
"x": 167,
"y": 48
},
{
"x": 197,
"y": 48
},
{
"x": 197,
"y": 67
},
{
"x": 167,
"y": 67
}
],
"word": "h"
}
]
}
],
"location": [
{
"x": 119,
"y": 48
},
{
"x": 199,
"y": 48
},
{
"x": 199,
"y": 69
},
{
"x": 119,
"y": 69
}
],
"fieldWord": "John Smith"
},
{
"prob": 1,
"fieldName": "Gender",
"fieldWordRaw": "Male",
"wordInfo": [
{
"prob": 0.99,
"location": [
{
"x": 117,
"y": 93
},
{
"x": 142,
"y": 93
},
{
"x": 142,
"y": 112
},
{
"x": 117,
"y": 112
}
],
"word": "Male",
"charInfo": [
{
"prob": 0.99,
"location": [
{
"x": 117,
"y": 93
},
{
"x": 142,
"y": 93
},
{
"x": 142,
"y": 112
},
{
"x": 117,
"y": 112
}
],
"word": "Male"
}
]
}
],
"location": [
{
"x": 117,
"y": 93
},
{
"x": 142,
"y": 93
},
{
"x": 142,
"y": 112
},
{
"x": 117,
"y": 112
}
],
"fieldWord": "Male"
},
{
"prob": 1,
"fieldName": "ID Number",
"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": "Ethnicity",
"fieldWordRaw": "Han",
"wordInfo": [
{
"prob": 0.99,
"location": [
{
"x": 232,
"y": 94
},
{
"x": 259,
"y": 94
},
{
"x": 259,
"y": 112
},
{
"x": 232,
"y": 112
}
],
"word": "Han",
"charInfo": [
{
"prob": 0.99,
"location": [
{
"x": 232,
"y": 94
},
{
"x": 259,
"y": 94
},
{
"x": 259,
"y": 112
},
{
"x": 232,
"y": 112
}
],
"word": "Han"
}
]
}
],
"location": [
{
"x": 232,
"y": 94
},
{
"x": 259,
"y": 94
},
{
"x": 259,
"y": 112
},
{
"x": 232,
"y": 112
}
],
"fieldWord": "Han"
}
],
"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.