Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import gradio as gr
|
|
| 5 |
import torch
|
| 6 |
import easyocr
|
| 7 |
|
| 8 |
-
# Download
|
| 9 |
urls = {
|
| 10 |
"english.png": "https://github.com/JaidedAI/EasyOCR/raw/master/examples/english.png",
|
| 11 |
"thai.jpg": "https://github.com/JaidedAI/EasyOCR/raw/master/examples/thai.jpg",
|
|
@@ -38,7 +38,16 @@ def inference(img_file, lang):
|
|
| 38 |
df.columns = ["text", "confidence"]
|
| 39 |
return "result.jpg", df
|
| 40 |
|
| 41 |
-
choices = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
examples = [
|
| 44 |
["english.png", ["en"]],
|
|
@@ -52,17 +61,18 @@ examples = [
|
|
| 52 |
|
| 53 |
with gr.Blocks(css=".output_image, .input_image {height: 40rem; width: 100%;}") as demo:
|
| 54 |
|
| 55 |
-
gr.Markdown("# **EasyOCR**")
|
|
|
|
| 56 |
|
| 57 |
with gr.Row():
|
| 58 |
file_input = gr.File(label="Upload Image", file_types=["image"])
|
| 59 |
-
lang_input = gr.CheckboxGroup(choices=choices, value=["en"], label="
|
| 60 |
|
| 61 |
run_btn = gr.Button("Run OCR")
|
| 62 |
|
| 63 |
with gr.Row():
|
| 64 |
output_img = gr.Image(label="Detected Image")
|
| 65 |
-
output_df = gr.Dataframe(headers=["text", "confidence"])
|
| 66 |
|
| 67 |
gr.Examples(examples, [file_input, lang_input], [output_img, output_df], fn=inference)
|
| 68 |
|
|
|
|
| 5 |
import torch
|
| 6 |
import easyocr
|
| 7 |
|
| 8 |
+
# Download example images
|
| 9 |
urls = {
|
| 10 |
"english.png": "https://github.com/JaidedAI/EasyOCR/raw/master/examples/english.png",
|
| 11 |
"thai.jpg": "https://github.com/JaidedAI/EasyOCR/raw/master/examples/thai.jpg",
|
|
|
|
| 38 |
df.columns = ["text", "confidence"]
|
| 39 |
return "result.jpg", df
|
| 40 |
|
| 41 |
+
choices = [
|
| 42 |
+
"abq","ady","af","ang","ar","as","ava","az",
|
| 43 |
+
"be","bg","bh","bho","bn","bs","ch_sim","ch_tra",
|
| 44 |
+
"che","cs","cy","da","dar","de","en","es","et","fa","fr","ga",
|
| 45 |
+
"gom","hi","hr","hu","id","inh","is","it","ja","kbd","kn","ko",
|
| 46 |
+
"ku","la","lbe","lez","lt","lv","mah","mai","mi","mn","mr","ms",
|
| 47 |
+
"mt","ne","new","nl","no","oc","pi","pl","pt","ro","ru","rs_cyrillic",
|
| 48 |
+
"rs_latin","sck","sk","sl","sq","sv","sw","ta","tab","te","th","tjk",
|
| 49 |
+
"tl","tr","ug","uk","ur","uz","vi"
|
| 50 |
+
]
|
| 51 |
|
| 52 |
examples = [
|
| 53 |
["english.png", ["en"]],
|
|
|
|
| 61 |
|
| 62 |
with gr.Blocks(css=".output_image, .input_image {height: 40rem; width: 100%;}") as demo:
|
| 63 |
|
| 64 |
+
gr.Markdown("# **EasyOCR Web Interface**")
|
| 65 |
+
gr.Markdown("Upload an image, select languages, and run OCR.")
|
| 66 |
|
| 67 |
with gr.Row():
|
| 68 |
file_input = gr.File(label="Upload Image", file_types=["image"])
|
| 69 |
+
lang_input = gr.CheckboxGroup(choices=choices, value=["en"], label="Languages")
|
| 70 |
|
| 71 |
run_btn = gr.Button("Run OCR")
|
| 72 |
|
| 73 |
with gr.Row():
|
| 74 |
output_img = gr.Image(label="Detected Image")
|
| 75 |
+
output_df = gr.Dataframe(headers=["text", "confidence"], label="Detected Text")
|
| 76 |
|
| 77 |
gr.Examples(examples, [file_input, lang_input], [output_img, output_df], fn=inference)
|
| 78 |
|