keras-ocr
文档地址
参考文章
错误集合
pip install ‘numpy1.19’ --force-reinstall 重装库版本
pip install 'h5py2.10.0’ --force-reinstall
code example
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
# 要一批识别默认的三张图,大概需要预留8g内存,这里只贴两张
images = [
keras_ocr.tools.read(url) for url in [
# 'https://upload.wikimedia.org/wikipedia/commons/b/bd/Army_Reserves_Recruitment_Banner_MOD_45156284.jpg',
'http://5b0988e595225.cdn.sohucs.com/images/20170905/44ecb27c4e5349e28abcbff8f3a6d4d2.jpeg',
'https://upload.wikimedia.org/wikipedia/commons/b/b4/EUBanana-500x112.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=(20, 20))
for ax, image, predictions in zip(axs, images, prediction_groups):
keras_ocr.tools.drawAnnotations(image=image, predictions=predictions, ax=ax)
# keras_ocr.tools.drawAnnotations(image=images[-1], predictions=prediction_groups[-1], ax=axs)
plt.show()
效果图