为文档 AI OCR API 请求设置 processOptions

huangapple go评论54阅读模式
英文:

Set processOptions for doc ai ocr api request

问题

我们建议在我们的OCR处理器上激活一个标志以获得更好的结果,因为我们面临一些问题(比如 "I" 被解析为 "1")。为了测试这个标志,我想使用Postman,但是在我的请求中添加选项会导致错误。

我的请求:

{
  "skipHumanReview": true,
  "processOptions": {
    ...
  },
  "rawDocument": {
    "mimeType": "application/pdf",
    "content": "..."
  },
  "fieldMask": "text,pages.blocks,pages.paragraphs,pages.formFields"
}

在没有 processOptions 部分的情况下,请求运行正常。但是 processOptions 未被识别。结果如下:

{
  ...
  "message": "Invalid JSON payload received. Unknown name \"processOptions\": Cannot find field."
  ...
}

所使用的处理器版本是 pretrained-ocr-v1.2-2022-11-10。我不知道是否使用了错误的版本(我看到的是最新的版本),还是我的请求有问题(我没有找到带有此标志的示例)。在我们的应用程序中,我们不使用提供的包,而是使用自定义代码(APEX)构建请求,因此我使用那种方式也会遇到同样的问题。

更新:
我找到了一些示例,我确信我的请求是正确的。那么我猜这必须是版本的问题,但 pretrained-ocr-v1.2-2022-11-10 是我可以获取到的最新版本。

为文档 AI OCR API 请求设置 processOptions

有人能解释为什么吗?

英文:

We are recommended to activate a flag on our OCR processor for better results because we face some problems (like "I" parsed as "1". To test the flag I want to use Postman, but adding the options to my requests results in an error.
My Request:

{

 "skipHumanReview": true,
 "processOptions": {
    ...
  },

  "rawDocument": {
    "mimeType": "application/pdf",
    "content": "..."
  },

  "fieldMask": "text,pages.blocks,pages.paragraphs,pages.formFields"

}

Without the processOptions part, the requests works fine. ProcessOptions is not recognized. The Result is:

{
...
"message": "Invalid JSON payload received. Unknown name "processOptions": Cannot find field."
...
}

The processor version used is pretrained-ocr-v1.2-2022-11-10
I don't know if I have a wrong version (the one used is the newest I see) or if my request is wrong (I didn't find an example with this flag).
In our application we don't use the provided packages, but build the requests with custom code (APEX), so I will have the same problem using that.

Update:
I found some examples and I am sure, that my request is correct. Then I guess it has to be the version, but pretrained-ocr-v1.2-2022-11-10 is the newset one I get offered
为文档 AI OCR API 请求设置 processOptions

Can somebody explain why?

答案1

得分: 0

目前,只有在使用 v1beta3 终端时才能指定 ProcessOptionshttps://documentai.googleapis.com/v1beta3

此文档显示如何将该字段添加到 processRequest

此 Python 示例显示如何向 ocr_config 添加一些选项,一旦这些选项添加到 v1 终端中,官方示例将会更新以包括此字段。

https://github.com/GoogleCloudPlatform/document-ai-samples/tree/main/pdf-embedded-text

关于此问题的先前答案:

英文:

Currently, ProcessOptions can only be specified when using the v1beta3 endpoint. https://documentai.googleapis.com/v1beta3

This documentation shows how to add the field to the processRequest

This Python sample shows how to add some options to ocr_config the official samples will be updated to include this field once the options are added to the v1 endpoint.

https://github.com/GoogleCloudPlatform/document-ai-samples/tree/main/pdf-embedded-text

Previous Answers about this:

huangapple
  • 本文由 发表于 2023年7月3日 22:22:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76605647.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定