Spaces:
Runtime error
Runtime error
Commit
·
f2e2f27
1
Parent(s):
20eb6b1
Upload 4 files
Browse files- app.py +25 -0
- demo.png +0 -0
- packages.txt +1 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image
|
| 2 |
+
import pytesseract
|
| 3 |
+
import gradio as gr
|
| 4 |
+
blocks = gr.Blocks()
|
| 5 |
+
|
| 6 |
+
def run_khm_eng(image):
|
| 7 |
+
result = pytesseract.image_to_string(
|
| 8 |
+
image, lang="khm+eng")
|
| 9 |
+
return result
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
with gr.Blocks() as demo:
|
| 13 |
+
gr.Markdown("## English+Khmer OCR")
|
| 14 |
+
with gr.Row():
|
| 15 |
+
with gr.Column():
|
| 16 |
+
image_in = gr.Image(type="pil")
|
| 17 |
+
btn = gr.Button("Run")
|
| 18 |
+
with gr.Column():
|
| 19 |
+
text_out = gr.TextArea()
|
| 20 |
+
|
| 21 |
+
examples = gr.Examples([["./demo.png", None]], fn=run_khm_eng, inputs=[
|
| 22 |
+
image_in], outputs=[text_out], cache_examples=False)
|
| 23 |
+
btn.click(fn=run_khm_eng, inputs=[image_in], outputs=[text_out])
|
| 24 |
+
|
| 25 |
+
demo.launch()
|
demo.png
ADDED
|
packages.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
tesseract-ocr-khm
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==3.32.0
|
| 2 |
+
Pillow==9.5.0
|
| 3 |
+
pytesseract==0.3.10
|