Spaces:
Runtime error
Runtime error
Upload app.py with huggingface_hub
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
|
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()
|
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,
|
25 |
+
article=article,
|
26 |
+
examples=[['eurotext.png', ['eng']], ['tesseract_sample.png', ['jpn', 'eng']], ['chi.jpg', ['HanS', 'HanT']]]
|
27 |
+
).launch(enable_queue=True,cache_examples=True)
|
28 |
+
|