pragnakalp
commited on
Commit
•
8c1efc2
1
Parent(s):
c7ac52a
Update app.py
Browse files
app.py
CHANGED
@@ -50,27 +50,13 @@ Keras OCR
|
|
50 |
"""
|
51 |
@spaces.GPU
|
52 |
def ocr_with_keras(img):
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
# return output_text
|
61 |
-
|
62 |
-
|
63 |
-
# Path to Tesseract executable (you may need to change this)
|
64 |
-
pytesseract.pytesseract.tesseract_cmd = r'<path_to_tesseract_executable>'
|
65 |
-
|
66 |
-
# Load the image
|
67 |
-
image = Image.open(img)
|
68 |
-
|
69 |
-
# Perform OCR on the image
|
70 |
-
output_text = pytesseract.image_to_string(image)
|
71 |
-
|
72 |
-
# Print the extracted text
|
73 |
-
print(output_text)
|
74 |
return output_text
|
75 |
|
76 |
"""
|
|
|
50 |
"""
|
51 |
@spaces.GPU
|
52 |
def ocr_with_keras(img):
|
53 |
+
output_text = ''
|
54 |
+
pipeline=keras_ocr.pipeline.Pipeline()
|
55 |
+
images=[keras_ocr.tools.read(img)]
|
56 |
+
predictions=pipeline.recognize(images)
|
57 |
+
first=predictions[0]
|
58 |
+
for text,box in first:
|
59 |
+
output_text += ' '+ text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
return output_text
|
61 |
|
62 |
"""
|