Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -81,9 +81,20 @@ def process_input(image=None, file=None, audio=None, text=""):
|
|
81 |
if file is not None:
|
82 |
if file.name.lower().endswith(('.png', '.jpg', '.jpeg')):
|
83 |
pil_image = Image.open(file)
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
85 |
elif file.name.lower().endswith('.pdf'):
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
else:
|
88 |
final_text += "\nUnsupported file type."
|
89 |
if audio is not None:
|
|
|
81 |
if file is not None:
|
82 |
if file.name.lower().endswith(('.png', '.jpg', '.jpeg')):
|
83 |
pil_image = Image.open(file)
|
84 |
+
ocr_prediction = ocr_processor.process_image(pil_image)
|
85 |
+
# gettig text from ocr object
|
86 |
+
for idx in range(len((list(ocr_prediction)[0][1]))):
|
87 |
+
final_text += " "
|
88 |
+
final_text += list((list(ocr_prediction)[0][1])[idx])[1][1]
|
89 |
+
print(final_text)
|
90 |
elif file.name.lower().endswith('.pdf'):
|
91 |
+
ocr_prediction = ocr_processor.process_pdf(file.name)
|
92 |
+
# gettig text from ocr object
|
93 |
+
for idx in range(len((list(ocr_prediction)[0][1]))):
|
94 |
+
final_text += " "
|
95 |
+
final_text += list((list(ocr_prediction)[0][1])[idx])[1][1]
|
96 |
+
print(final_text)
|
97 |
+
# final_text += "\n" + ocr_processor.process_pdf(file.name)
|
98 |
else:
|
99 |
final_text += "\nUnsupported file type."
|
100 |
if audio is not None:
|