Spaces:
Runtime error
Runtime error
File size: 1,253 Bytes
5951cdf fef5ee3 5951cdf fef5ee3 1cc44c4 fef5ee3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
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()
|