|
import cv2 |
|
import pytesseract |
|
import gradio as gr |
|
|
|
|
|
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) |
|
text = pytesseract.image_to_string(gray) |
|
return text |
|
|
|
|
|
|
|
|
|
iface = gr.Interface( |
|
fn=extract_text_from_image, |
|
inputs=gr.Image(numpy="file", label="Upload Image"), |
|
outputs="text", |
|
title="OCR APP ", |
|
description="Upload an image and we'll extract the text for you.", |
|
layout="unaligned", |
|
) |
|
|
|
|
|
iface.launch(share=True) |
|
|
|
|