from PIL import Image | |
import gradio as gr | |
import pytesseract | |
def ocr(input_img): | |
pil_image = Image.fromarray(input_img.astype('uint8')) | |
gray_image = pil_image.convert('L') | |
text = pytesseract.image_to_string(gray_image) | |
return text | |
demo = gr.Interface(ocr, gr.Image(), outputs="text") | |
demo.launch() | |