napatswift commited on
Commit
0fc4b93
1 Parent(s): f8610ca
Files changed (2) hide show
  1. main.py +25 -0
  2. requirements.txt +1 -1
main.py CHANGED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from mmocr.ocr import MMOCR
2
+ import gradio as gr
3
+ import cv2
4
+
5
+ model_dir = 'work_dirs/dbnet_resnet18_fpnc_1200e_icdar2015'
6
+ ocr = MMOCR(det='DB_r18',
7
+ det_config=f'{model_dir}/dbnet_resnet18_fpnc_1200e_icdar2015.py',
8
+ det_ckpt=f'{model_dir}/epoch_40.pth'
9
+ )
10
+
11
+ def predict(inp):
12
+ return str(ocr.readtext(inp))
13
+
14
+ def run():
15
+ demo = gr.Interface(
16
+ fn=predict,
17
+ inputs=gr.inputs.Image(),
18
+ outputs=gr.outputs.Textbox(),
19
+ )
20
+
21
+ demo.launch(server_name="0.0.0.0", server_port=7860)
22
+
23
+
24
+ if __name__ == "__main__":
25
+ run()
requirements.txt CHANGED
@@ -1,7 +1,7 @@
 
1
  gradio
2
  torch
3
  torchvision
4
- requests
5
  openmim
6
  mmdet>=3.0.0rc0
7
  mmocr>=1.0.0rc0
 
1
+ opencv-python
2
  gradio
3
  torch
4
  torchvision
 
5
  openmim
6
  mmdet>=3.0.0rc0
7
  mmocr>=1.0.0rc0