PredictModel

更新时间:
复制 MD 格式

Model prediction supports information extraction from long documents, single receipts, and tables.

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.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

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 do not specify this parameter, the system uses the latest active version of the model by default.

1

ModelId

integer

Yes

The model ID. You can find the model ID on the Model List page.

123

BinaryToText

boolean

No

Specifies how the input document is provided. Set this to true if you provide the document content as a base64-encoded string in the Body parameter. Set this to false if you provide the document's URL in the Content parameter.

false:表示content传入的是url true:表示body是直接传入图片进行base64的内容

Body

string

No

The base64-encoded content of the image file. Use this parameter when BinaryToText is set to true.

data:image/png;base64,xxxxx

The BinaryToText parameter is optional.

You must specify either the Content parameter with the document's URL or the Body parameter with the document's base64-encoded content. If you use the Body parameter, you must also set BinaryToText to true.

PDF files are limited to 20 MB and 10 pages. For prediction types other than long-document extraction, the service processes only the first page.

Response elements

Element

Type

Description

Example

object

The response data.

RequestId

string

The request ID.

3EAC98E6-8DD6-511F-8764-DEE8B6EB6BB4

Code

integer

The status code of the request. A value of 200 indicates success.

200

Message

string

The returned message. If the request fails, this parameter contains the error message.

success

Data

object

The returned data object.

{ "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 }

The following describes the fields in the Data object for long-document information extraction.

originalFileUrl     The URL of the original file.
predictFile         An array of image URLs parsed from the document that are used for prediction.
data                The detailed prediction results.
angle               The rotation angle of the image. This field is returned only when `NeedRotate` is `true`. 0 indicates upright, 90 indicates rotated to the right, 180 indicates upside down, and 270 indicates rotated to the left.
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, which is the size of the `prism_wordsInfo` array.

The following describes the fields in the prism_wordsInfo array:

angle                The 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 coordinates of the four points of the bounding rectangle for the text block, arranged clockwise: top-left, top-right, bottom-right, and bottom-left. If `NeedRotate` is `true` and the `angle` of the parent object is not 0, these coordinates are accurate only after you correct the image based on the parent `angle`.
word                 The text content of the block.
tableId              This field exists if `OutputTable` is `true` and the text block is within a table. It indicates the ID of the table.
tableCellId          This field exists if `OutputTable` is `true` and the text block is within a table. It indicates the ID of the table cell.

The following describes the fields for single-character information (charInfo):

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.

The following describes the fields in the prism_tablesInfo array:

tableId            The ID of the table, which corresponds to the `tableId` in the `prism_wordsInfo` object.
xCellSize          The number of cells along the x-axis (columns).
yCellSize          The number of cells along the y-axis (rows).

The following describes the fields for cell information (cellInfos), which includes the spatial topology of cells within the entire table:

tableCellId        The ID of the table cell, which corresponds to the `tableCellId` in the `prism_wordsInfo` object.
word               The text content of the cell.
xsc                `xsc` (xStartCell): The starting column index of the cell. The index is 0-based.
xec                `xec` (xEndCell): The ending column index of the cell. The index is 0-based. If `xsc` and `xec` are both 0, the cell spans one column and is in the first column.
ysc                `ysc` (yStartCell): The starting row index of the cell. The index is 0-based.
yec                `yec` (yEndCell): The ending row index of the cell. The index is 0-based.
pos                The coordinates of the four corners of the cell, arranged clockwise: 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 Codes for a complete list.

Release notes

See Release Notes for a complete list.