Spaces:
Runtime error
Runtime error
import gradio as gr | |
import cv2 | |
import pytesseract | |
import numpy as np | |
from PIL import Image | |
import urllib | |
def process_image(image): | |
image = np.array(image) | |
# gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) | |
# gray, img_bin = cv2.threshold(gray,128,255,cv2.THRESH_BINARY | cv2.THRESH_OTSU) | |
# gray = cv2.bitwise_not(img_bin) | |
# kernel = np.ones((2, 1), np.uint8) | |
# img = cv2.erode(gray, kernel, iterations=1) | |
# img = cv2.dilate(img, kernel, iterations=1) | |
generated_text = pytesseract.image_to_string(image) | |
return generated_text | |
title = "Interactive demo: tesseract" | |
description = "Demo for tesseract ocr" | |
article = "<p style='text-align: center'></p>" | |
examples =[["image_0.png"]] | |
iface = gr.Interface(fn=process_image, | |
inputs=gr.Image(type="pil"), | |
outputs="text", | |
title=title, | |
description=description, | |
article=article) | |
iface.launch(debug=True) |