added keras support

This commit is contained in:
2023-02-05 13:30:06 +10:00
parent c671fb9bf6
commit a2894791e2
2 changed files with 21 additions and 24 deletions

17
scripts/keras.py Normal file
View File

@@ -0,0 +1,17 @@
import io
import sys
import base64
import numpy as np
import keras_ocr
if len(sys.argv) > 1:
# Decode the base64-encoded image
img = base64.b64decode(sys.argv[1])
img = np.array(bytearray(img), dtype=np.uint8)
# Use Keras-OCR to recognize text in the image
pipeline = keras_ocr.pipeline.Pipeline()
prediction = pipeline.recognize([img])
# Return the recognized text
print prediction[0][0]['text']