Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,12 +9,12 @@ import urllib
|
|
9 |
def process_image(image):
|
10 |
image = np.array(image)
|
11 |
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
generated_text = pytesseract.image_to_string(img)
|
19 |
|
20 |
return generated_text
|
|
|
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(img)
|
19 |
|
20 |
return generated_text
|