(self)
| 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 |
no test coverage detected