【发布时间】:2020-10-08 10:52:57
【问题描述】:
我想使用 Textract OCR 服务从 pdf 文件中读取文本。我有一个问题,因为我想在本地做,没有 S3 桶。我对图像文件进行了测试,效果很好,但不适用于 PDF 文件。
这是我得到错误的代码:
response = textract.start_document_text_detection(DocumentLocation="sample2.pdf")
错误:
Invalid type for parameter DocumentLocation, value: sample2.pdf, type: <class 'str'>, valid types: <class 'dict'>
代码2:
response = textract.start_document_text_detection(DocumentLocation={"name":"sample2.pdf"})
错误:
Unknown parameter in DocumentLocation: "name", must be one of: S3Object
代码3:
response = textract.start_document_text_detection(Document={'Bytes': "sample2.pdf"})
错误:
Unknown parameter in input: "Document", must be one of: DocumentLocation, ClientRequestToken, JobTag, NotificationChannel, OutputConfig
我该怎么办,有没有办法让 Textract 可以在没有 s3 的情况下处理 PDF 文档?
【问题讨论】:
-
我也在寻找同样的东西。是的,您可以在本地文件上使用 AWS Textract。但是您必须将文件(.pdf,.jpg ...)转换为
Bytesdocs.aws.amazon.com/textract/latest/dg/API_Document.html
标签: python ocr amazon-textract