Spaces:
Paused
Paused
Commit
·
2509048
1
Parent(s):
5484471
Add application file
Browse files- app_blocks.py +6 -2
- app_interface.py +4 -2
app_blocks.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
import pytesseract
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
image = Image.open(filepath)
|
| 7 |
return pytesseract.image_to_string(image=image, lang=', '.join(languages) if languages else None)
|
| 8 |
|
|
@@ -10,6 +13,7 @@ title = "Tesseract OCR"
|
|
| 10 |
description = "Gradio demo for Tesseract. Tesseract is an open source text recognition (OCR) Engine."
|
| 11 |
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>"
|
| 12 |
examples = [
|
|
|
|
| 13 |
["examples/eurotext.png", ["eng"]],
|
| 14 |
["examples/tesseract_sample.png", ["jpn", "eng"]],
|
| 15 |
["examples/chi.jpg", ["HanS", "HanT"]],
|
|
|
|
| 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]=None):
|
| 9 |
image = Image.open(filepath)
|
| 10 |
return pytesseract.image_to_string(image=image, lang=', '.join(languages) if languages else None)
|
| 11 |
|
|
|
|
| 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 |
examples = [
|
| 16 |
+
["examples/weird_unicode_math_symbols.png", []]
|
| 17 |
["examples/eurotext.png", ["eng"]],
|
| 18 |
["examples/tesseract_sample.png", ["jpn", "eng"]],
|
| 19 |
["examples/chi.jpg", ["HanS", "HanT"]],
|
app_interface.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
|
|
|
|
|
| 1 |
import pytesseract
|
| 2 |
from PIL import Image
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
-
def tesseract_ocr(filepath, languages):
|
| 7 |
image = Image.open(filepath)
|
| 8 |
return pytesseract.image_to_string(image=image, lang=', '.join(languages))
|
| 9 |
|
|
@@ -32,4 +34,4 @@ demo = gr.Interface(
|
|
| 32 |
)
|
| 33 |
|
| 34 |
if __name__ == '__main__':
|
| 35 |
-
demo.launch(
|
|
|
|
| 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 |
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
if __name__ == '__main__':
|
| 37 |
+
demo.launch()
|