首页 > 解决方案 > MLkIT 的文本识别不识别非英文文本

问题描述

我在 IOS 上实现了 MLkit 的文本识别,但它无法识别非英文文本(例如阿拉伯文本)。

它仅适用于英语。

这是文档 https://developers.google.com/ml-kit/vision/text-recognition/ios

我的代码:

        let textRecognizer = TextRecognizer.textRecognizer()
        let visionImage = VisionImage(image: image)

        textRecognizer.process(visionImage) { result, error in
            guard error == nil, let result = result else { return }
            let resultText = result.text
            print("MLKit : " + resultText)
        }

标签: iosswiftocrtext-recognitiongoogle-mlkit

解决方案


更新:如果不需要完全在本地(在没有网络的设备上),您可以尝试 MLKit for cloud,它支持“100 多种不同的语言和脚本”。Firebase 文本识别

对于本地推理:Google 的“MLKit 文本识别”基于“TensorFlow Lite”,它使用本地模型来识别文本。根据我的研究,Google 并未声明预定义模型专门用于拉丁字母。但似乎是这样。所以你现在有三个选择:

  1. 寻找针对阿拉伯字母进行训练的自定义“TensorFlow Lite”模型。
  2. 训练自己的“TensorFlow Lite”模型:TensorFlow Lite Model Maker
  3. 查找/训练“张量流”模型(不是精简版!)并将其转换为“TensorFlow Lite”模型

推荐阅读