如何使 keras-ocr 默认模型仅识别数字?

Вла*_*мов 5 python ocr number-recognition keras

我使用 python 和 keras ocr。我希望 keras 只识别数字,所以在管道中我这样做。

recognizer = keras_ocr.recognition.Recognizer(alphabet="0123456789")
pipeline = keras_ocr.pipeline.Pipeline(recognizer=recognizer)
Run Code Online (Sandbox Code Playgroud)

但它并没有像超立方体白名单那样将字母转换为数字并提高识别质量。 识别号码错误 所以这些数字根本不被识别。

使用默认字母识别的数字 使用默认字母表结果更好。但有些数字与字母混淆。然而,将字母更改为数字,如“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()
Run Code Online (Sandbox Code Playgroud)

Вла*_*мов 1

我还没有找到比使用 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