Vihang28 commited on
Commit
24ba624
·
verified ·
1 Parent(s): 8c81564

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -1,19 +1,26 @@
1
  import gradio as gr
2
  from symspellpy import SymSpell
3
 
 
 
 
 
 
 
 
4
  with gr.Blocks(title=title) as demo:
5
  gr.Markdown(f'<h1 style="text-align: center; margin-bottom: 1rem;">{title}</h1>')
6
  gr.Markdown(description)
7
  with gr.Row():
8
  with gr.Column():
9
- image = gr.Textbox(placeholder="Enter Text..", label="Input")
10
  with gr.Row():
11
  btn_clear = gr.ClearButton([image])
12
  btn_submit = gr.Button(value="Submit", variant="primary")
13
  with gr.Column():
14
  text = gr.Textbox(label="Output")
15
 
16
- btn_submit.click(ocr_model, inputs=[image], outputs=text, api_name="PaddleOCR")
17
  btn_clear.add(text)
18
 
19
  gr.Markdown(article)
 
1
  import gradio as gr
2
  from symspellpy import SymSpell
3
 
4
+ def ocr_model(inp_text):
5
+ symsp = SymSpell()
6
+ symsp.load_dictionary('freq_dictionay_symspellpy.txt',term_index=0, count_index=1, separator=' ')
7
+ sentence = inp_text
8
+ terms = symsp.lookup_compound(sentence,max_edit_distance=2)
9
+ return terms[0].term
10
+
11
  with gr.Blocks(title=title) as demo:
12
  gr.Markdown(f'<h1 style="text-align: center; margin-bottom: 1rem;">{title}</h1>')
13
  gr.Markdown(description)
14
  with gr.Row():
15
  with gr.Column():
16
+ inp_text = gr.Textbox(placeholder="Enter Text..", label="Input")
17
  with gr.Row():
18
  btn_clear = gr.ClearButton([image])
19
  btn_submit = gr.Button(value="Submit", variant="primary")
20
  with gr.Column():
21
  text = gr.Textbox(label="Output")
22
 
23
+ btn_submit.click(text_checker, inputs=[inp_text], outputs=text)
24
  btn_clear.add(text)
25
 
26
  gr.Markdown(article)