-
Notifications
You must be signed in to change notification settings - Fork 7
/
config.py
196 lines (161 loc) · 7.28 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# -*- coding:utf-8 -*-
class Config(object):
# server parmas
host = '0.0.0.0'
use_gpu = True
ir_optim = True
enable_mkldnn = False
gpu_mem = 8000
save_dir = "./received_imgs"
language_map = {"ENG": "en", "JAP": "japan", "KOR": "korean", "CH": "ch", "CH_h": "ch_h", "French": 'french',
"German": 'german'}
baidu_translate_app_id = ["20201017000591885"]
baidu_translate_secret_key = ["CK6fgXm9h3heLd4HWoqD"]
language_map_reverse = {v: k for k, v in language_map.items()}
# params for text detector
det_algorithm = "DB"
det_model_dir = "./inference/det_db/ch_ppocr_server_v1.1_det_infer/"
# det_model_dir = "./output/det_r18_vd_db/best_accuracy_infer/"
det_max_side_len = 960
# DB parmas
det_db_thresh = 0.3
det_db_box_thresh = 0.5
det_db_unclip_ratio = 1.8 # 2.0
# EAST parmas
det_east_score_thresh = 0.8
det_east_cover_thresh = 0.1
det_east_nms_thresh = 0.2
use_zero_copy_run = False
use_pdserving = False
assert len(baidu_translate_app_id) == len(baidu_translate_secret_key)
def update(self, language):
if language == "japan" or language == self.language_map_reverse["japan"]:
self.update_jap()
elif language == "en" or language == self.language_map_reverse["en"]:
self.update_eng()
elif language == "korean" or language == self.language_map_reverse["korean"]:
self.update_korean()
elif language == "ch" or language == self.language_map_reverse["ch"]:
self.update_chinese()
elif language == "ch_h" or language == self.language_map_reverse["ch_h"]:
self.update_chinese_high()
elif language == "french" or language == self.language_map_reverse["french"]:
self.update_french()
elif language == "german" or language == self.language_map_reverse["german"]:
self.update_german()
else:
print("language not right: {}".format(language))
raise NotImplementedError
def update_jap(self):
# params for text recognizer
self.rec_algorithm = "CRNN"
self.rec_model_dir = "./inference/rec_crnn/japan_ppocr_mobile_v1.1_rec_infer/"
# self.rec_model_dir = "./output/rec_japan/best_accuracy_infer/"
self.rec_image_shape = "3, 32, 800" # "3, 32, 320"
self.rec_char_type = 'japan' # "en", "ch", 'japan', 'korean', 'french', 'german'
self.rec_batch_num = 4
self.max_text_length = 25 # 50
self.rec_char_dict_path = "ppocr/utils/dict/japan_dict.txt"
self.use_space_char = False
self.use_angle_cls = False
self.cls_model_dir = "./inference/cls/ch_ppocr_mobile_v1.1_cls_infer/"
self.cls_image_shape = "3, 48, 192"
self.label_list = ['0', '180']
self.cls_batch_num = 30
self.cls_thresh = 0.9
def update_eng(self):
# params for text recognizer
self.rec_algorithm = "CRNN"
self.rec_model_dir = "./inference/rec_crnn/en_ppocr_mobile_v1.1_rec_infer/"
self.rec_image_shape = "3, 32, 320"
self.rec_char_type = 'ch' # "en", "ch", 'japan', 'korean', 'french', 'german'
self.rec_batch_num = 4
self.max_text_length = 30
self.rec_char_dict_path = "./ppocr/utils/ic15_dict.txt"
self.use_space_char = True
self.use_angle_cls = False
self.cls_model_dir = "./inference/cls/ch_ppocr_mobile_v1.1_cls_infer/"
self.cls_image_shape = "3, 48, 192"
self.label_list = ['0', '180']
self.cls_batch_num = 30
self.cls_thresh = 0.9
def update_korean(self):
# params for text recognizer
self.rec_algorithm = "CRNN"
self.rec_model_dir = "./inference/rec_crnn/korean_ppocr_mobile_v1.1_rec_infer/"
self.rec_image_shape = "3, 32, 320"
self.rec_char_type = 'korean' # "en", "ch", 'japan', 'korean', 'french', 'german'
self.rec_batch_num = 4
self.max_text_length = 25
self.rec_char_dict_path = "./ppocr/utils/dict/korean_dict.txt"
self.use_space_char = False
self.use_angle_cls = False
self.cls_model_dir = "./inference/cls/ch_ppocr_mobile_v1.1_cls_infer/"
self.cls_image_shape = "3, 48, 192"
self.label_list = ['0', '180']
self.cls_batch_num = 30
self.cls_thresh = 0.9
def update_chinese(self):
# params for text recognizer
self.rec_algorithm = "CRNN"
self.rec_model_dir = "./inference/rec_crnn/ch_ppocr_mobile_v1.1_rec_infer/"
self.rec_image_shape = "3, 32, 320"
self.rec_char_type = 'ch' # "en", "ch", 'japan', 'korean', 'french', 'german'
self.rec_batch_num = 4
self.max_text_length = 25
self.rec_char_dict_path = "./ppocr/utils/ppocr_keys_v1.txt"
self.use_space_char = True
self.use_angle_cls = False # True
self.cls_model_dir = "./inference/cls/ch_ppocr_mobile_v1.1_cls_infer/"
self.cls_image_shape = "3, 48, 192"
self.label_list = ['0', '180']
self.cls_batch_num = 30
self.cls_thresh = 0.9
def update_chinese_high(self):
# params for text recognizer
self.rec_algorithm = "CRNN"
self.rec_model_dir = "./inference/rec_crnn/ch_ppocr_server_v1.1_rec_infer/"
self.rec_image_shape = "3, 32, 320"
self.rec_char_type = 'ch' # "en", "ch", 'japan', 'korean', 'french', 'german'
self.rec_batch_num = 4
self.max_text_length = 25
self.rec_char_dict_path = "./ppocr/utils/ppocr_keys_v1.txt"
self.use_space_char = True
self.use_angle_cls = False # True
self.cls_model_dir = "./inference/cls/ch_ppocr_mobile_v1.1_cls_infer/"
self.cls_image_shape = "3, 48, 192"
self.label_list = ['0', '180']
self.cls_batch_num = 30
self.cls_thresh = 0.9
def update_french(self):
# params for text recognizer
self.rec_algorithm = "CRNN"
self.rec_model_dir = "./inference/rec_crnn/french_ppocr_mobile_v1.1_rec_infer/"
self.rec_image_shape = "3, 32, 320"
self.rec_char_type = 'french' # "en", "ch", 'japan', 'korean', 'french', 'german'
self.rec_batch_num = 4
self.max_text_length = 25
self.rec_char_dict_path = "./ppocr/utils/dict/french_dict.txt"
self.use_space_char = False
self.use_angle_cls = False
self.cls_model_dir = "./inference/cls/ch_ppocr_mobile_v1.1_cls_infer/"
self.cls_image_shape = "3, 48, 192"
self.label_list = ['0', '180']
self.cls_batch_num = 30
self.cls_thresh = 0.9
def update_german(self):
# params for text recognizer
self.rec_algorithm = "CRNN"
self.rec_model_dir = "./inference/rec_crnn/german_ppocr_mobile_v1.1_rec_infer/"
self.rec_image_shape = "3, 32, 320"
self.rec_char_type = 'german' # "en", "ch", 'japan', 'korean', 'french', 'german'
self.rec_batch_num = 4
self.max_text_length = 25
self.rec_char_dict_path = "./ppocr/utils/dict/german_dict.txt"
self.use_space_char = False
self.use_angle_cls = False
self.cls_model_dir = "./inference/cls/ch_ppocr_mobile_v1.1_cls_infer/"
self.cls_image_shape = "3, 48, 192"
self.label_list = ['0', '180']
self.cls_batch_num = 30
self.cls_thresh = 0.9