File size: 511 Bytes
21e6b2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
import easyocr
import numpy as np

def perform_ocr(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:
    with gr.Tab("Extract Text"):
        image_input = gr.inputs.Image()
        text_output = gr.outputs.Textbox()
        button = gr.Button("Perform OCR")

    button.click(perform_ocr, inputs=image_input, outputs=text_output)

demo.launch()