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() |