This commit is contained in:
2023-02-06 09:49:21 +10:00
parent a7e06bef91
commit f9105577ce
2 changed files with 146 additions and 137 deletions

View File

@@ -1,17 +1,13 @@
import io
import sys
import base64
import urllib.parse
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
url = urllib.parse.unquote(sys.argv[1])
image = keras_ocr.tools.read(url)
pipeline = keras_ocr.pipeline.Pipeline()
prediction = pipeline.recognize([img])
# Return the recognized text
print prediction[0][0]['text']
prediction = pipeline.recognize([image])
print("----------START----------")
for text, box in prediction [0]:
print(text)