如何使用pillow和keras读取和打开文件

tkqqtvp1  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(190)

我想使用keras ocr,但文档说明了图像的静态输入。我想能够上传文件,并在此基础上提取ocr。
使用PyteSeract,pillow可用于打开和读取文件:

text = pytesseract.image_to_data(Image.open(
       filename), lang='eng', config='--psm 6')
return text

如何使用keras(image.open)和枕头实现这一点?
当前代码:

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)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题