Spaces:
Sleeping
Sleeping
Delete app_interface.py
Browse files- app_interface.py +0 -38
app_interface.py
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
from typing import List
|
2 |
-
|
3 |
-
import pytesseract
|
4 |
-
from PIL import Image
|
5 |
-
|
6 |
-
import gradio as gr
|
7 |
-
|
8 |
-
def tesseract_ocr(filepath: str, languages: List[str]):
|
9 |
-
image = Image.open(filepath)
|
10 |
-
return pytesseract.image_to_string(image=image, lang=', '.join(languages))
|
11 |
-
|
12 |
-
title = "Tesseract OCR"
|
13 |
-
description = "Optical Character Recognition"
|
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 |
-
examples = [
|
16 |
-
['examples/eurotext.png', ['eng']],
|
17 |
-
['examples/tesseract_sample.png', ['jpn', 'eng']],
|
18 |
-
['examples/chi.jpg', ['HanS', 'HanT']]
|
19 |
-
]
|
20 |
-
|
21 |
-
language_choices = pytesseract.get_languages()
|
22 |
-
|
23 |
-
demo = gr.Interface(
|
24 |
-
fn=tesseract_ocr,
|
25 |
-
inputs=[
|
26 |
-
gr.Image(type="filepath", label="Input"),
|
27 |
-
gr.CheckboxGroup(language_choices, type="value", value=['eng'], label='language')
|
28 |
-
],
|
29 |
-
outputs='text',
|
30 |
-
title=title,
|
31 |
-
description=description,
|
32 |
-
article=article,
|
33 |
-
examples=examples,
|
34 |
-
)
|
35 |
-
|
36 |
-
if __name__ == '__main__':
|
37 |
-
demo.launch()
|
38 |
-
print("Finished running")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|