3v324v23 commited on
Commit
866dcbc
·
1 Parent(s): bdc12ec
Files changed (1) hide show
  1. app.py +22 -3
app.py CHANGED
@@ -1,6 +1,8 @@
1
  import streamlit as st
 
2
  import os
3
  import cv2
 
4
 
5
  def get_image_path(img):
6
  # Create a directory and save the uploaded image.
@@ -15,7 +17,24 @@ if uploaded_file is not None:
15
  # Get actual image file
16
  fpath= get_image_path(uploaded_file)
17
  st.image(fpath)
18
- item = cv2.imread(fpath)
19
- item = cv2.cvtColor(item, cv2.COLOR_BGR2GRAY)
 
 
 
 
20
 
21
- st.image(item)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import json
3
  import os
4
  import cv2
5
+ from utils import draw_ocr_results, start_ocr
6
 
7
  def get_image_path(img):
8
  # Create a directory and save the uploaded image.
 
17
  # Get actual image file
18
  fpath= get_image_path(uploaded_file)
19
  st.image(fpath)
20
+ res = start_ocr({
21
+ 'image_dir': fpath,
22
+ 'drop_score': 0.3,
23
+ #'det_model_dir': "./paddle/ch_PP-OCRv3_det_infer",
24
+ 'det_model_dir': "./paddle/ch_PP-OCRv4_det_infer",
25
+ #'det_model_dir': "./paddle/ch_PP-OCRv4_det_server_infer",
26
 
27
+ #'rec_model_dir': "./paddle/ch_PP-OCRv3_rec_infer",
28
+ 'rec_model_dir': "./paddle/ch_PP-OCRv4_rec_infer",
29
+ #'rec_model_dir': "./paddle/ch_PP-OCRv4_rec_server_infer",
30
+
31
+ 'det_limit_side_len': 2496,
32
+ "det_db_box_thresh": 0.2,
33
+
34
+ "use_angle_cls": False,
35
+ #"cls_model_dir": "./paddle/ch_ppocr_mobile_v2.0_cls_infer",
36
+ "rec_char_dict_path": './paddle/ppocr_keys_v1.txt',
37
+ "show_log": True,
38
+ })
39
+
40
+ st.write(json.dumps(res))