Youssouf Traore
commited on
Commit
·
94affbe
1
Parent(s):
84772c2
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
import pytesseract
|
3 |
from PIL import Image
|
4 |
-
|
5 |
def extract_text(image):
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
#
|
10 |
-
|
11 |
-
print(
|
12 |
-
|
|
|
|
|
13 |
|
14 |
# Définir l'interface utilisateur Gradio
|
15 |
inputs = gr.inputs.Image()
|
|
|
1 |
import gradio as gr
|
2 |
import pytesseract
|
3 |
from PIL import Image
|
4 |
+
import cv2
|
5 |
def extract_text(image):
|
6 |
+
|
7 |
+
img_cv = cv2.imread(image)
|
8 |
+
# By default OpenCV stores images in BGR format and since pytesseract assumes RGB format,
|
9 |
+
# we need to convert from BGR to RGB format/mode:
|
10 |
+
img_rgb = cv2.cvtColor(img_cv, cv2.COLOR_BGR2RGB)
|
11 |
+
print(pytesseract.image_to_string(img_rgb))
|
12 |
+
# OR
|
13 |
+
img_rgb = Image.frombytes('RGB', img_cv.shape[:2], img_cv, 'raw', 'BGR', 0, 0)
|
14 |
+
print(pytesseract.image_to_string(img_rgb))
|
15 |
|
16 |
# Définir l'interface utilisateur Gradio
|
17 |
inputs = gr.inputs.Image()
|