Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,18 +29,18 @@ def perform_ocr_on_images(images):
|
|
| 29 |
ocr_results.append(text)
|
| 30 |
return "\n".join(ocr_results)
|
| 31 |
|
| 32 |
-
def ocr_marathi_from_pdf(
|
| 33 |
"""
|
| 34 |
Main function to handle Marathi OCR from a PDF file.
|
| 35 |
"""
|
| 36 |
-
images = extract_images_from_pdf(
|
| 37 |
ocr_text = perform_ocr_on_images(images)
|
| 38 |
return ocr_text
|
| 39 |
|
| 40 |
# Define the Gradio interface
|
| 41 |
interface = gr.Interface(
|
| 42 |
fn=ocr_marathi_from_pdf,
|
| 43 |
-
inputs=gr.File(type="
|
| 44 |
outputs=gr.Textbox(label="Extracted Marathi Text"),
|
| 45 |
title="Marathi PDF OCR",
|
| 46 |
description="Upload a PDF containing Marathi text. The app will extract the text using OCR.",
|
|
@@ -49,3 +49,4 @@ interface = gr.Interface(
|
|
| 49 |
if __name__ == "__main__":
|
| 50 |
interface.launch()
|
| 51 |
|
|
|
|
|
|
| 29 |
ocr_results.append(text)
|
| 30 |
return "\n".join(ocr_results)
|
| 31 |
|
| 32 |
+
def ocr_marathi_from_pdf(pdf_file_path):
|
| 33 |
"""
|
| 34 |
Main function to handle Marathi OCR from a PDF file.
|
| 35 |
"""
|
| 36 |
+
images = extract_images_from_pdf(pdf_file_path) # Use the file path from the upload
|
| 37 |
ocr_text = perform_ocr_on_images(images)
|
| 38 |
return ocr_text
|
| 39 |
|
| 40 |
# Define the Gradio interface
|
| 41 |
interface = gr.Interface(
|
| 42 |
fn=ocr_marathi_from_pdf,
|
| 43 |
+
inputs=gr.File(type="filepath", label="Upload Marathi PDF"), # Fixed the type here
|
| 44 |
outputs=gr.Textbox(label="Extracted Marathi Text"),
|
| 45 |
title="Marathi PDF OCR",
|
| 46 |
description="Upload a PDF containing Marathi text. The app will extract the text using OCR.",
|
|
|
|
| 49 |
if __name__ == "__main__":
|
| 50 |
interface.launch()
|
| 51 |
|
| 52 |
+
|