Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import easyocr | |
| import numpy as np | |
| def perform_ocr(image): | |
| reader = easyocr.Reader(['en']) | |
| result = reader.readtext(image, paragraph=False) | |
| return result | |
| def perform_ocr1(image): | |
| reader = easyocr.Reader(['en'], gpu=False) | |
| result = reader.readtext(image) | |
| ocr_text = '\n'.join([entry[1] for entry in result]) | |
| return ocr_text | |
| with gr.Blocks() as demo: | |
| gr.Markdown("OCR (Optical Character Recognition) methods use algorithms to analyze images, recognize characters, and convert them into editable text. Popular tools like Tesseract OCR, Google Cloud Vision API, and Microsoft Azure Cognitive Services OCR efficiently perform this task, enabling data extraction and document digitization from images.") | |
| with gr.Tab("OCR Function 1"): | |
| image_input1 = gr.inputs.Image() | |
| text_output1 = gr.outputs.Textbox() | |
| button1 = gr.Button("Perform OCR") | |
| with gr.Tab("OCR Function 2"): | |
| image_input2 = gr.inputs.Image() | |
| text_output2 = gr.outputs.Textbox() | |
| button2 = gr.Button("Perform OCR") | |
| button1.click(perform_ocr, inputs=image_input1, outputs=text_output1) | |
| button2.click(perform_ocr1, inputs=image_input2, outputs=text_output2) | |
| demo.launch() | |