Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
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,
|