shibing624 commited on
Commit
6303e29
·
verified ·
1 Parent(s): 2beb0f2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ @author:XuMing([email protected])
4
+ @description: pip install gradio
5
+ """
6
+
7
+ import gradio as gr
8
+ from imgocr import ImgOcr
9
+ model = ImgOcr()
10
+
11
+
12
+ def get_text(img_path):
13
+ ocr_result = model.ocr(img_path)[0]
14
+ print("{} \t\t {}".format(img_path, ocr_result))
15
+ ocr_text = [i[-1][0] for i in ocr_result]
16
+ r = '\n'.join(ocr_text)
17
+ print(r)
18
+ return r
19
+
20
+
21
+ if __name__ == '__main__':
22
+ examples = [
23
+ ['data/1.jpg'],
24
+ ['data/11.jpg'],
25
+ ['data/12.jpg'],
26
+ ['data/00111002.jpg'],
27
+ ]
28
+ gr.Interface(
29
+ get_text,
30
+ inputs=['image'],
31
+ outputs='text',
32
+ title="imgocr: Image OCR",
33
+ description="Input an image, and the machine will output the OCR result.",
34
+ article="Link to <a href='https://github.com/shibing624/imgocr' style='color:blue;' target='_blank\'>Github REPO</a>",
35
+ examples=examples
36
+ ).launch()