File size: 775 Bytes
7975e87 | 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 | import gradio as gr
import easyocr
# Initialize the EasyOCR Reader
reader = easyocr.Reader(['en'], gpu=False) # Set gpu=True if GPU is available
def extract_text_from_image(image):
# Perform OCR on the image
results = reader.readtext(image)
# Extract detected text
extracted_text = "\n".join([result[1] for result in results])
return extracted_text
# Define Gradio Interface
interface = gr.Interface(
fn=extract_text_from_image, # Function to run
inputs=gr.Image(type="filepath"), # Upload an image
outputs="text", # Display extracted text
title="Image Text Extractor",
description="Upload an image to extract text using OCR."
)
# Launch the app
if __name__ == "__main__":
interface.launch()
|