Xianbao QIAN commited on
Commit
d3ff6da
1 Parent(s): 466c88a
Files changed (4) hide show
  1. app.py +23 -0
  2. demo_text_det.jpg +0 -0
  3. demo_text_ocr.jpg +0 -0
  4. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import mmocr
2
+ import gradio as gr
3
+ import os
4
+ from huggingface_hub import hf_hub_url
5
+ from mmocr.utils.ocr import MMOCR
6
+
7
+
8
+ # The default config path is based the current woking directory.
9
+ config_dir = os.path.join(os.path.dirname(
10
+ os.path.dirname(mmocr.__file__)), 'configs/')
11
+
12
+ # TODO: Put the model on HF hub.
13
+ ocr = MMOCR(config_dir=config_dir)
14
+ results = ocr.readtext('demo_text_ocr.jpg',
15
+ output='.', print_result=True, imshow=True)
16
+
17
+ def infer(image):
18
+ # TODO: Also display bounding boxes
19
+ return ocr.readtext(image, output='.', print_result=True, imshow=False)
20
+
21
+ # TODO: Add a dropbox for model selection
22
+ iface = gr.Interface(fn=infer, inputs="image", outputs="json")
23
+ iface.launch()
demo_text_det.jpg ADDED
demo_text_ocr.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ mmcv-full
2
+ mmdet
3
+ mmmmocr
4
+ gradio
5
+ git+https://github.com/xianbaoqian/mmocr.git