Spaces:
Runtime error
Runtime error
Commit
·
4adb0d9
1
Parent(s):
e5901da
Update app.py
Browse files
app.py
CHANGED
@@ -3,17 +3,17 @@ import gradio as gr
|
|
3 |
from PIL import Image
|
4 |
import pytesseract
|
5 |
|
6 |
-
def extract_text_from_image(
|
7 |
try:
|
8 |
-
|
9 |
-
text = pytesseract.image_to_string(
|
10 |
return text
|
11 |
except Exception as e:
|
12 |
return str(e)
|
13 |
|
14 |
iface = gr.Interface(
|
15 |
fn=extract_text_from_image,
|
16 |
-
inputs=gr.Image(type="
|
17 |
outputs="text",
|
18 |
live=True,
|
19 |
)
|
|
|
3 |
from PIL import Image
|
4 |
import pytesseract
|
5 |
|
6 |
+
def extract_text_from_image(image):
|
7 |
try:
|
8 |
+
pil_image = Image.fromarray(image)
|
9 |
+
text = pytesseract.image_to_string(pil_image)
|
10 |
return text
|
11 |
except Exception as e:
|
12 |
return str(e)
|
13 |
|
14 |
iface = gr.Interface(
|
15 |
fn=extract_text_from_image,
|
16 |
+
inputs=gr.Image(type="pil", label="Upload an image"),
|
17 |
outputs="text",
|
18 |
live=True,
|
19 |
)
|