tomofi commited on
Commit
9292a6a
1 Parent(s): 2b246a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -4,17 +4,21 @@ import gradio as gr
4
  print(os.popen(f'cat /etc/debian_version').read())
5
  print(os.popen(f'cat /etc/issue').read())
6
  print(os.popen(f'apt search tesseract').read())
7
- print(os.popen(f'tesseract --list-langs').read())
8
 
9
- def inference(filepath):
10
- return os.popen(f'tesseract {filepath} -').read().strip()
 
 
 
 
 
11
 
12
  title = "Tesseract OCR"
13
  description = "Gradio demo for Tesseract. Tesseract is an open source text recognition (OCR) Engine."
14
  article = "<p style='text-align: center'><a href='https://tesseract-ocr.github.io/' target='_blank'>Tesseract documentation</a> | <a href='https://github.com/tesseract-ocr/tesseract' target='_blank'>Github Repo</a></p>"
15
  gr.Interface(
16
  inference,
17
- [gr.inputs.Image(type="filepath", label="Input")],
18
  'text',
19
  title=title,
20
  description=description,
 
4
  print(os.popen(f'cat /etc/debian_version').read())
5
  print(os.popen(f'cat /etc/issue').read())
6
  print(os.popen(f'apt search tesseract').read())
 
7
 
8
+ choices = os.popen('tesseract --list-langs').read().split('\n')[1:-1]
9
+
10
+ def inference(filepath, languages):
11
+ print('languages', languages)
12
+ languages_str = '-l ' + '+'.join(languages) if languages else ''
13
+ print('languages_str', languages_str)
14
+ return os.popen(f'tesseract {filepath} -{languages_str}').read().strip()
15
 
16
  title = "Tesseract OCR"
17
  description = "Gradio demo for Tesseract. Tesseract is an open source text recognition (OCR) Engine."
18
  article = "<p style='text-align: center'><a href='https://tesseract-ocr.github.io/' target='_blank'>Tesseract documentation</a> | <a href='https://github.com/tesseract-ocr/tesseract' target='_blank'>Github Repo</a></p>"
19
  gr.Interface(
20
  inference,
21
+ [gr.inputs.Image(type="filepath", label="Input"), gr.inputs.CheckboxGroup(choices, type="value", default=['eng'], label='language')],
22
  'text',
23
  title=title,
24
  description=description,