Spaces:
Runtime error
Runtime error
File size: 855 Bytes
fae5fde d4bb32d fae5fde 46f53c6 fae5fde b8e0f00 fae5fde 72cb518 fae5fde 0552eaf |
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 cv2
import pytesseract
import gradio as gr
# ------------------------- Function to extract text from an image -------------------------
def extract_text_from_image(image):
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # Convert the image from BGR to grayscale
text = pytesseract.image_to_string(gray) # Extract text from the grayscale image
return text
#------------------------------- Graphic interface --------------------------------
# Define Gradio interface
iface = gr.Interface(
fn=extract_text_from_image,
inputs=gr.image (label="Upload Image"),
outputs="text",
title="OCR APP ",
description="Upload an image and we'll extract the text for you.",
)
# Launch Gradio Interface
iface.launch(share= True)
|