如何使用 Microsoft Azure 计算机视觉 AI 提高图像中文本读取的准确性

问题描述 投票:0回答:1

我是 Microsoft Azure AI 计算机视觉新手。我在 Python 程序中使用认知服务和计算机视觉客户端来做两件事:

  1. 使用光学字符识别 (OCR) 从 JPG 图像中提取文本
  2. 使用认知服务提供图像描述

经过大量配置问题(以及 PIP 安装!),我取得了一些成果

从图像中提取文本的代码是:

#Create A ComputerVision Client
client = ComputerVisionClient(ENDPOINT, CognitiveServicesCredentials(API_KEY))

image_path = '/Users/Owner/Documents/Bills Stuff/eBay/Images/Document_20240914_0008.jpg'  

#Use Azure AI Cognitive Services to Get the Title and Description of Image
#For the TITLE, Use Optical Character Recognition (OCR) to Read the Text (Caption) on the Image
with open(image_path, "rb") as image_stream:
      ocr_results=client.recognize_printed_text_in_stream(image_stream)

if ocr_results.regions:
    for region in ocr_results.regions:
            for line in region.lines:
                    print(f"   Title: {' '.join([word.text for word in line.words])}")

我的第二点 - 描述效果很好,但是上面的代码根本没有从图像中准确地提取文本。

它很接近,但实际的文字是:“宾夕法尼亚铁路马蹄曲线风景”

我上面提供的代码返回:“中国铁路马蹄曲线内”

有没有办法改进我的代码,使这个结果更加准确?

添加:如果我减小/增加图像的大小,代码会拾取更多或更少的单词 - 也许我需要以某种方式给代码更多的时间来处理图像??

谢谢!

python azure ocr azure-cognitive-services
1个回答
0
投票

我建议您考虑将 Azure AI Vision v4.0 与 Azure OpenAI GPT4-Turbo 与 Vision 结合起来。

这个概念是,您首先使用 GPT4-Turbo with Vision 模型处理图像,这将帮助您分析图像并提供有关您提供的图像中可读文本位置的详细信息。您应该考虑使用视力增强选项。

使用此信息,您的 OCR 结果应该会有所改善。尽管如此,您必须记住,处理每个单独图像的成本会明显增加,因为您基本上会处理图像两次。

您可以在此处查看 Microsoft 相关文档。

© www.soinside.com 2019 - 2024. All rights reserved.