PredictModel
Use this operation for three types of model prediction: long document information extraction, single-document information extraction, and table information extraction.
Try it now
Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.
Test
RAM authorization
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Content |
string |
No |
The URL of the image or PDF file. |
https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/extractBill.png |
| ModelVersion |
string |
No |
The version of the model. If you omit this parameter, the service uses the latest active version by default. |
1 |
| ModelId |
integer |
Yes |
The model ID. You can obtain the model ID on the Model List page. |
123 |
| BinaryToText |
boolean |
No |
Specifies the format of the input file. |
false:表示content传入的是url true:表示body是直接传入图片进行base64的内容 |
| Body |
string |
No |
The base64-encoded content of the image. |
data:image/png;base64,xxxxx |
The BinaryToText parameter is optional.
Specify either the Content parameter for an image URL or the Body parameter for base64-encoded content. If you use Body, you must also set BinaryToText to true.
PDF files cannot exceed 20 MB or 10 pages. For model prediction types other than long document information extraction, the service processes only the first page of the document.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response object. |
||
| RequestId |
string |
The unique ID of the request. |
3EAC98E6-8DD6-511F-8764-DEE8B6EB6BB4 |
| Code |
integer |
The status code of the request. A value of |
200 |
| Message |
string |
The response message. Returns "success" for a successful request or an error message if the request fails. |
success |
| Data |
object |
The response 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 } |
Description of fields in the Data object for long document information extraction models
originalFileUrl: The URL of the original file.
predictFile: A collection of image URLs, created by parsing the original file, used for prediction.
data: The specific prediction results.
angle: The rotation angle of the image. This field is returned only when `NeedRotate` is set to `true`. A value of 0 indicates the original orientation, 90 indicates a clockwise rotation, 180 indicates a 180-degree rotation, and 270 indicates a counterclockwise rotation. If `NeedRotate` is `true`, you must rotate the image according to this angle to use the returned coordinates.
content: A summary of the text blocks recognized in the image.
height: The height of the image after algorithmic correction.
width: The width of the image after algorithmic correction.
orgHeight: The height of the original image.
orgWidth: The width of the original image.
prism_wnum: The number of recognized text blocks. This value matches the size of the `prism_wordsInfo` array.
Description of fields in the prism_wordsInfo array
angle: The rotation angle of the text block. This angle only affects the `width` and `height` values. If the angle is -90, 90, -270, or 270, you must swap the `width` and `height` values.
height: The height of the text block.
width: The width of the text block.
pos: The four corner coordinates of the text block's bounding box, listed clockwise: top-left, top-right, bottom-right, and bottom-left. If `NeedRotate` is `true` and the top-level `angle` is not 0, you must rotate the image according to the top-level angle to use these coordinates.
word: The text content of the block.
tableId: The ID of the table containing this text block. This ID matches a `tableId` in the `prism_tablesInfo` array. Returned only if `OutputTable` is `true` and the text block is in a table.
tableCellId: The ID of the cell containing this text block. This ID matches a `tableCellId` in the `cellInfos` array. Returned only if `OutputTable` is `true` and the text block is in a table cell.
charInfo: Individual character information
word: The character.
x: The x-coordinate of the character's top-left corner.
y: The y-coordinate of the character's top-left corner.
w: The width of the character.
h: The height of the character.
Description of fields in the prism_tablesInfo array
tableId: The unique ID for the table. This ID is referenced by the `tableId` field in `prism_wordsInfo` objects.
xCellSize: The number of cells along the x-axis (columns) in the table.
yCellSize: The number of cells along the y-axis (rows) in the table.
cellInfos: Information about table cells, including their layout and structure.
tableCellId: The unique ID for the cell. This ID is referenced by the `tableCellId` field in `prism_wordsInfo` objects.
word: The text content of the cell.
xsc: Abbreviation for `xStartCell`. The starting column index for the cell, where the first column is 0.
xec: Abbreviation for `xEndCell`. The ending column index for the cell, where the first column is 0. If `xsc` and `xec` are both 0, this indicates a single cell in the first column.
ysc: Abbreviation for `yStartCell`. The starting row index for the cell, where the first row is 0.
yec: Abbreviation for `yEndCell`. The ending row index for the cell, where the first row is 0.
pos: The coordinates of the cell's corners, listed in clockwise order: top-left (X, Y), top-right (X, Y), bottom-right (X, Y), and bottom-left (X, Y).
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 CodesError Codes for a complete list.
Release notes
See Release NotesRelease Notes for a complete list.