| New file |
| | |
| | | |
| | | environment: ubuntu20.04-py37-torch1.11.0-tf1.15.5-1.2.0 |
| | | |
| | | Export onnx files from modelscope |
| | | ```python |
| | | from funasr.export.export_model import ASRModelExportParaformer |
| | | |
| | | output_dir = "../export" |
| | | export_model = ASRModelExportParaformer(cache_dir=output_dir, onnx=True) |
| | | export_model.export_from_modelscope('damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch') |
| | | ``` |
| | | |
| | | |
| | | Export onnx files from local path |
| | | ```python |
| | | from funasr.export.export_model import ASRModelExportParaformer |
| | | |
| | | output_dir = "../export" |
| | | export_model = ASRModelExportParaformer(cache_dir=output_dir, onnx=True) |
| | | export_model.export_from_local('/root/cache/export/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch') |
| | | ``` |
| | |
| | | model, |
| | | self.export_config, |
| | | ) |
| | | if self.onnx: |
| | | self._export_onnx(model, verbose, export_dir) |
| | | self._export_onnx(model, verbose, export_dir) |
| | | # if self.onnx: |
| | | # self._export_onnx(model, verbose, export_dir) |
| | | # else: |
| | | # self._export_torchscripts(model, verbose, export_dir) |
| | | |
| | | logging.info("output dir: {}".format(export_dir)) |
| | | |
| | | |
| | | def _export_torchscripts(self, model, verbose, path, enc_size=None): |
| | | if enc_size: |
| | | dummy_input = model.get_dummy_inputs(enc_size) |
| | | else: |
| | | dummy_input = model.get_dummy_inputs() |
| | | |
| | | # model_script = torch.jit.script(model) |
| | | model_script = torch.jit.trace(model, dummy_input) |
| | | model_script.save(os.path.join(path, f'{model.model_name}.torchscripts')) |
| | | |
| | | def export_from_modelscope( |
| | | self, |
| | | tag_name: str = 'damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch', |