MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / _init_common

Method _init_common

tools/infer_rec.py:267–284  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

265 raise ValueError("backend参数必须是'torch'或'onnx'")
266
267 def _init_common(self):
268 # 初始化公共组件
269 from openrec.postprocess import build_post_process
270 from openrec.preprocess import create_operators, transform
271 self.transform = transform
272 # 构建预处理流程
273 algorithm_name = self.cfg['Architecture']['algorithm']
274 if algorithm_name in ['SVTRv2_mobile', 'SVTRv2_server']:
275 self.cfg['Global']['character_dict_path'] = DEFAULT_DICT_PATH_REC
276 self.post_process_class = build_post_process(self.cfg['PostProcess'],
277 self.cfg['Global'])
278 char_num = self.post_process_class.get_character_num()
279 self.cfg['Architecture']['Decoder']['out_channels'] = char_num
280 transforms, ratio_resize_flag = build_rec_process(self.cfg)
281 self.ops = create_operators(transforms, self.cfg['Global'])
282 if ratio_resize_flag:
283 ratio_resize = RatioRecTVReisze(cfg=self.cfg)
284 self.ops.insert(-1, ratio_resize)
285
286 def _init_torch_model(self, numId):
287 from tools.utils.ckpt import load_ckpt

Callers 1

__init__Method · 0.95

Calls 5

build_post_processFunction · 0.90
create_operatorsFunction · 0.90
build_rec_processFunction · 0.85
RatioRecTVReiszeClass · 0.85
get_character_numMethod · 0.45

Tested by

no test coverage detected