Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,25 +8,25 @@ import urllib
|
|
8 |
|
9 |
def process_image(image):
|
10 |
image = np.array(image)
|
11 |
-
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
|
12 |
-
gray, img_bin = cv2.threshold(gray,128,255,cv2.THRESH_BINARY | cv2.THRESH_OTSU)
|
13 |
-
gray = cv2.bitwise_not(img_bin)
|
14 |
|
15 |
-
kernel = np.ones((2, 1), np.uint8)
|
16 |
-
img = cv2.erode(gray, kernel, iterations=1)
|
17 |
-
img = cv2.dilate(img, kernel, iterations=1)
|
18 |
-
generated_text = pytesseract.image_to_string(
|
19 |
|
20 |
return generated_text
|
21 |
|
22 |
-
title = "Interactive demo:
|
23 |
description = "Demo for tesseract ocr"
|
24 |
article = "<p style='text-align: center'></p>"
|
25 |
examples =[["image_0.png"]]
|
26 |
|
27 |
iface = gr.Interface(fn=process_image,
|
28 |
-
inputs=gr.
|
29 |
-
outputs=
|
30 |
title=title,
|
31 |
description=description,
|
32 |
article=article)
|
|
|
8 |
|
9 |
def process_image(image):
|
10 |
image = np.array(image)
|
11 |
+
# gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
|
12 |
+
# gray, img_bin = cv2.threshold(gray,128,255,cv2.THRESH_BINARY | cv2.THRESH_OTSU)
|
13 |
+
# gray = cv2.bitwise_not(img_bin)
|
14 |
|
15 |
+
# kernel = np.ones((2, 1), np.uint8)
|
16 |
+
# img = cv2.erode(gray, kernel, iterations=1)
|
17 |
+
# img = cv2.dilate(img, kernel, iterations=1)
|
18 |
+
generated_text = pytesseract.image_to_string(image)
|
19 |
|
20 |
return generated_text
|
21 |
|
22 |
+
title = "Interactive demo: tesseract"
|
23 |
description = "Demo for tesseract ocr"
|
24 |
article = "<p style='text-align: center'></p>"
|
25 |
examples =[["image_0.png"]]
|
26 |
|
27 |
iface = gr.Interface(fn=process_image,
|
28 |
+
inputs=gr.Image(type="pil"),
|
29 |
+
outputs="text",
|
30 |
title=title,
|
31 |
description=description,
|
32 |
article=article)
|