【发布时间】:2021-07-08 08:20:16
【问题描述】:
我正在使用 Keras OCR 的示例从图像中检测文本。使用官方文档中提供的示例代码,我使用预训练的权重获得了很好的准确性。 我打算使用 OCR 字符串来比较文本中检测到的一些模式。为了能够创建应用程序,我正在使用 Flask。
我想打印从 OCR 行接收到的字符串。目前,输出返回带有文本(单个单词)的图像。我希望只能打印从 OCR 行接收到的字符串。我怎样才能做到这一点?
代码:
import matplotlib.pyplot as plt
import keras_ocr
# keras-ocr will automatically download pretrained
# weights for the detector and recognizer.
pipeline = keras_ocr.pipeline.Pipeline()
# Get a set of three example images
images = [
keras_ocr.tools.read(url) for url in [
'https://upload.wikimedia.org/wikipedia/commons/b/b4/EUBanana-500x112.jpg',
'abc.jpg'
]
]
# Each list of predictions in prediction_groups is a list of
# (word, box) tuples.
prediction_groups = pipeline.recognize(images)
# Plot the predictions
fig, axs = plt.subplots(nrows=len(images), figsize=(90, 90))
for ax, image, predictions in zip(axs, images, prediction_groups):
keras_ocr.tools.drawAnnotations(image=image, predictions=predictions, ax=ax)
【问题讨论】: