lingjun.zlj
commited on
Commit
·
afb39ec
1
Parent(s):
6b055ec
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import pytesseract
|
| 4 |
+
|
| 5 |
+
def ocr(input_img):
|
| 6 |
+
pil_image = Image.fromarray(input_img.astype('uint8'))
|
| 7 |
+
gray_image = pil_image.convert('L')
|
| 8 |
+
text = pytesseract.image_to_string(gray_image)
|
| 9 |
+
return text
|
| 10 |
+
|
| 11 |
+
demo = gr.Interface(ocr, gr.Image(), outputs="text")
|
| 12 |
+
demo.launch()
|