File size: 969 Bytes
a55334d
 
 
 
 
 
 
 
 
 
8e9c4a8
 
 
a55334d
8e9c4a8
 
 
 
a55334d
 
 
8e9c4a8
a55334d
edbee95
a55334d
 
 
8e9c4a8
 
a55334d
 
 
 
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
29
30
31
32
33
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)