Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -27,14 +27,15 @@ def draw_boxes(image, bounds, color='yellow', width=2):
|
|
27 |
return image
|
28 |
|
29 |
# 🔮 The core function that does the OCR wizardry
|
30 |
-
def inference(
|
31 |
# 🕵️♂️ Reading the image, please hold...
|
32 |
reader = easyocr.Reader(lang)
|
33 |
-
bounds = reader.readtext(
|
34 |
-
im = Image.open(
|
35 |
draw_boxes(im, bounds)
|
36 |
-
|
37 |
-
|
|
|
38 |
|
39 |
# 🚀 Time to set up the Gradio app!
|
40 |
def main():
|
@@ -57,11 +58,11 @@ def main():
|
|
57 |
|
58 |
with gr.Row():
|
59 |
with gr.Column():
|
60 |
-
img_input = gr.Image(type='
|
61 |
lang_input = gr.CheckboxGroup(choices, value=['en'], label='🗣️ Language(s)')
|
62 |
submit_btn = gr.Button("Start OCR 🕵️♂️")
|
63 |
with gr.Column():
|
64 |
-
img_output = gr.Image(type='
|
65 |
df_output = gr.Dataframe(headers=['Text', 'Confidence'])
|
66 |
|
67 |
gr.Examples(
|
|
|
27 |
return image
|
28 |
|
29 |
# 🔮 The core function that does the OCR wizardry
|
30 |
+
def inference(img_path, lang):
|
31 |
# 🕵️♂️ Reading the image, please hold...
|
32 |
reader = easyocr.Reader(lang)
|
33 |
+
bounds = reader.readtext(img_path)
|
34 |
+
im = Image.open(img_path)
|
35 |
draw_boxes(im, bounds)
|
36 |
+
result_path = 'result.jpg'
|
37 |
+
im.save(result_path)
|
38 |
+
return [result_path, pd.DataFrame(bounds).iloc[:, 1:]]
|
39 |
|
40 |
# 🚀 Time to set up the Gradio app!
|
41 |
def main():
|
|
|
58 |
|
59 |
with gr.Row():
|
60 |
with gr.Column():
|
61 |
+
img_input = gr.Image(type='filepath', label='📥 Input Image')
|
62 |
lang_input = gr.CheckboxGroup(choices, value=['en'], label='🗣️ Language(s)')
|
63 |
submit_btn = gr.Button("Start OCR 🕵️♂️")
|
64 |
with gr.Column():
|
65 |
+
img_output = gr.Image(type='filepath', label='📤 Output Image')
|
66 |
df_output = gr.Dataframe(headers=['Text', 'Confidence'])
|
67 |
|
68 |
gr.Examples(
|