PredictModel
Performs model prediction, which includes three types: long document information extraction, single receipt information extraction, and table information extraction.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
documentautoml:PredictModel |
get |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Content |
string |
No |
The URL for accessing the image or PDF file. |
https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/extractBill.png |
| ModelVersion |
string |
No |
The version number of the model. If this parameter is not specified, the latest effective version of the model is used by default. |
1 |
| ModelId |
integer |
Yes |
The model ID. You can obtain the model ID from the model list page. |
123 |
| 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: indicates that the Content field contains a URL. true: indicates that the Body field contains Base64-encoded image content |
| Body |
string |
No |
The Base64 encoding content of the image. |
data:image/png;base64,xxxxx |
BinaryToText is optional.
Specify either the Content field or the Body field. If you use an image URL, set Content to the image access address. If you use 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 prediction, other prediction services only process the first page.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Schema of Response |
||
| RequestId |
string |
Id of the request |
3EAC98E6-8DD6-511F-8764-DEE8B6EB6BB4 |
| Code |
integer |
The status of the request result. A value of 200 indicates success. |
200 |
| Message |
string |
The error message. |
success |
| Data |
object |
The response data returned by the operation. |
{ "RequestId": "0C066DD3-F55D-18F7-8577-DE533E04054D", "Message": "", "Data": { "code": 200, "data": { "姓名": "xxx", "证号": "xxx", "性别": "女" }, "specificType": "ocr_infoExtractBill", "originalFileUrl": "https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/extractBill.png", "message": "", "type": "卡证", "version": "1.0.9", "predictFile": "", "tim_img": "17", "score": 1.05, "wid": "1544", "hgt": "1054", "imageUrl": "", "angle": "0", "orig_hgt": "1054", "orig_wid": "1544", "tim_ocr": "97", "classType": "model", "info": [ { "value_loc": "595,314,595,399,398,399,398,314", "key_prob": 1, "key_loc": "", "value_prob": 1, "value": "XXX", "key": "姓名" }, { "value_loc": "1256,234,1256,312,678,312,678,233", "key_prob": 1, "key_loc": "", "value_prob": 1, "value": "440305198305101408", "key": "证号" }, { "value_loc": "965,321,965,394,851,394,851,321", "key_prob": 1, "key_loc": "", "value_prob": 1, "value": "女", "key": "性别" } ] }, "Code": 200 } |
Description of the data fields returned by the long document information extraction model:
originalFileUrl The URL of the original file.
predictFile The collection of image URLs parsed for prediction.
data The specific prediction results.
angle The angle of the image. This field is returned only when NeedRotate is set to true. 0 indicates upright, 90 indicates the image faces right, 180 indicates upside down, and 270 indicates the image faces left.
content The summary of recognized text blocks in the image.
height The height of the image after algorithm correction.
width The width of the image after algorithm correction.
orgHeight The height of the original image.
orgWidth The width of the original image.
prism_wnum The number of recognized text blocks, which is the size of the prism_wordsInfo array.
Description of fields in the prism-wordsInfo text block array:
angle The angle of the text block. This angle only affects width and height. When the angle is -90, 90, -270, or 270, you need to swap the width and height values.
height The height of the text block.
width The width of the text block.
pos The coordinates of the four corners of the bounding rectangle of the text block, arranged clockwise: top-left, top-right, bottom-right, bottom-left. When NeedRotate is set to true and the outer-level angle is not 0, the coordinates are accurate only after the image is corrected based on the angle.
word The text content of the text block.
tableId This field exists when OutputTable is set to true and the text block is inside a table. tableId indicates the ID of the table.
tableCellId This field exists when OutputTable is set to true and the text block is inside a table. It indicates the ID of the cell in the table.
charInfo single character information:
word The single character text.
x The x-coordinate of the top-left corner of the character.
y The y-coordinate of the top-left corner of the character.
w The width of the character.
h The height of the character.
Description of fields in the prism-tablesInfo table array:
tableId The table ID, which corresponds to the tableId in prism_wordsInfo.
xCellSize The number of cells along the horizontal axis in the table.
yCellSize The number of cells along the vertical axis in the table.
cellInfos cell information, which contains the spatial topology of the cell within the entire table:
tableCellId The cell ID in the table, which corresponds to the tableCellId in prism_wordsInfo.
word The text in the cell.
xsc Abbreviation for xStartCell. Indicates the starting cell position along the horizontal axis. The first cell has a value of 0.
xec Abbreviation for xEndCell. Indicates the ending cell position along the horizontal axis. The first cell has a value of 0. If both xsc and xec are 0, the text occupies one cell along the horizontal axis and is in the first cell.
ysc Abbreviation for yStartCell. Indicates the starting cell position along the vertical axis. The first cell has a value of 0.
yec Abbreviation for yEndCell. Indicates the ending cell position along the vertical axis. The first cell has a value of 0.
pos The cell position. The coordinates are arranged clockwise by the four corners of the cell: top-left XY, top-right XY, bottom-right XY, and bottom-left XY.
Examples
Success response
JSON format
{
"RequestId": "3EAC98E6-8DD6-511F-8764-DEE8B6EB6BB4",
"Code": 200,
"Message": "success",
"Data": {
"RequestId": "0C066DD3-F55D-18F7-8577-DE533E04054D",
"Message": "",
"Data": {
"code": 200,
"data": {
"姓名": "xxx",
"证号": "xxx",
"性别": "女"
},
"specificType": "ocr_infoExtractBill",
"originalFileUrl": "https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/extractBill.png",
"message": "",
"type": "卡证",
"version": "1.0.9",
"predictFile": "",
"tim_img": "17",
"score": 1.05,
"wid": "1544",
"hgt": "1054",
"imageUrl": "",
"angle": "0",
"orig_hgt": "1054",
"orig_wid": "1544",
"tim_ocr": "97",
"classType": "model",
"info": [
{
"value_loc": "595,314,595,399,398,399,398,314",
"key_prob": 1,
"key_loc": "",
"value_prob": 1,
"value": "XXX",
"key": "姓名"
},
{
"value_loc": "1256,234,1256,312,678,312,678,233",
"key_prob": 1,
"key_loc": "",
"value_prob": 1,
"value": "440305198305101408",
"key": "证号"
},
{
"value_loc": "965,321,965,394,851,394,851,321",
"key_prob": 1,
"key_loc": "",
"value_prob": 1,
"value": "女",
"key": "性别"
}
]
},
"Code": 200
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 200 | 21002 | 模板预测超时 | |
| 200 | 21003 | 模板预测失败 | |
| 200 | 10001 | 参数出错 | |
| 200 | 10005 | 服务不存在 | |
| 200 | 16001 | 未找到可预测的模型 | |
| 200 | 13018 | 未找到模型信息 | |
| 200 | 16004 | 指定的模型不存在 | |
| 200 | 23002 | 获取资源HTTP异常 | |
| 200 | 11002 | 账号没有开通服务 | |
| 200 | 19999 | 未知异常 |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.