簡體   English   中英

如何讓 keras-ocr 默認模型只識別數字?

[英]How make keras-ocr default model recognize only numbers?

我使用 python 和 keras ocr。 我希望 keras 只識別數字,所以在管道中我這樣做。

recognizer = keras_ocr.recognition.Recognizer(alphabet="0123456789")
pipeline = keras_ocr.pipeline.Pipeline(recognizer=recognizer)

但它並沒有像 tesseract 白名單那樣將字母轉換為數字並提高識別質量。 錯誤識別號碼 所以這些數字根本無法識別。

使用默認字母識別的數字 使用默認字母,結果會更好。 但有些數字與字母混淆。 但是,將字母更改為“replace("O", "0")" 之類的數字是一個非常糟糕的主意。

識別功能簡單且可復制:)


    _image = keras_ocr.tools.read(_path)
    plt.figure(figsize=(10, 20))
    plt.imshow(_image)

    prediction = pipeline.recognize([_image])[0]
    fig, axs = plt.subplots(1, figsize=(10, 20))
    keras_ocr.tools.drawAnnotations(image=_image, predictions=prediction, ax=axs)
    plt.show()

我沒有找到比使用 keras ocr 工具學習模型更簡單的方法。 然而,合成數據的文本生成器使用書籍、期刊或具有想法、意義的東西中的文本(我不知道用英語說:))。 所以數字很少,有時如果你的字母是“0123456789”,生成器會返回空字符串。 所以我寫了我自己的生成器,它只用數字生成字符串。 https://keras-ocr.readthedocs.io/en/latest/examples/end_to_end_training.html https://colab.research.google.com/drive/1PxxXyH3XaBoTgxKIoC9dKIRo4wUo-QDg#scrollTo=I7SF5VeoLulc

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM