sherpa-onnx icon indicating copy to clipboard operation
sherpa-onnx copied to clipboard

export 3d speaker campplus sv model to onnx error

Open lhanzl opened this issue 1 year ago • 0 comments

infer_sv.py from speakerlib(3dspeaker) and modify damo/speech_campplus_sv_zh-cn_16k-common to iic/speech_campplus_sv_zh-cn_16k-common

but some errors:

root@6e7e8c0b451c:~/3D-Speaker/sv_onnx# python export-onnx.py --model speech_campplus_sv_zh-cn_16k-common 2024-03-04 15:11:25,379 - modelscope - INFO - PyTorch version 2.0.1+cpu Found. 2024-03-04 15:11:25,386 - modelscope - INFO - TensorFlow version 2.13.0 Found. 2024-03-04 15:11:25,387 - modelscope - INFO - Loading ast index from /mnt/workspace/.cache/modelscope/ast_indexer 2024-03-04 15:11:25,457 - modelscope - INFO - Loading done! Current index file version is 1.9.5, with md5 79827826d04c54fc06982662c5095533 and a total number of 945 components indexed 2024-03-04 15:11:26,846 - modelscope - INFO - Use user-specified model revision: v2.0.0 {'framework': 'pytorch', 'task': 'speaker-verification', 'model_config': 'config.yaml', 'model_file': 'campplus_cn_common.bin', 'model': {'type': 'cam++-sv', 'model_config': {'sample_rate': 16000, 'fbank_dim': 80, 'emb_size': 192}, 'pretrained_model': 'campplus_cn_common.bin', 'yesOrno_thr': 0.31}, 'pipeline': {'type': 'speaker-verification'}} /opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py:2029: UserWarning: Provided key embeddings for dynamic axes is not a valid input/output name warnings.warn( ============== Diagnostic Run torch.onnx.export version 2.0.1+cpu ============== verbose: False, log level: Level.ERROR ======================= 0 NONE 0 NOTE 0 WARNING 0 ERROR ========================

Traceback (most recent call last): File "export-onnx.py", line 149, in main() File "/opt/conda/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "export-onnx.py", line 97, in main torch.onnx.export( File "/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py", line 506, in export _export( File "/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py", line 1548, in _export graph, params_dict, torch_out = _model_to_graph( File "/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py", line 1117, in _model_to_graph graph = _optimize_graph( File "/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py", line 665, in _optimize_graph graph = _C._jit_pass_onnx(graph, operator_export_type) File "/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py", line 1891, in _run_symbolic_function return symbolic_fn(graph_context, *inputs, **attrs) File "/opt/conda/lib/python3.8/site-packages/torch/onnx/symbolic_helper.py", line 392, in wrapper return fn(g, *args, **kwargs) File "/opt/conda/lib/python3.8/site-packages/torch/onnx/symbolic_helper.py", line 306, in wrapper return fn(g, args, **kwargs) File "/opt/conda/lib/python3.8/site-packages/torch/onnx/symbolic_opset11.py", line 625, in symbolic_fn padding_ceil = opset9.get_pool_ceil_padding( File "/opt/conda/lib/python3.8/site-packages/torch/onnx/symbolic_opset9.py", line 1501, in get_pool_ceil_padding return symbolic_helper._unimplemented( File "/opt/conda/lib/python3.8/site-packages/torch/onnx/symbolic_helper.py", line 607, in _unimplemented _onnx_unsupported(f"{op}, {msg}", value) File "/opt/conda/lib/python3.8/site-packages/torch/onnx/symbolic_helper.py", line 618, in _onnx_unsupported raise errors.SymbolicValueError( torch.onnx.errors.SymbolicValueError: Unsupported: ONNX export of operator get_pool_ceil_padding, input size not accessible. Please feel free to request support or submit a pull request on PyTorch GitHub: https://github.com/pytorch/pytorch/issues [Caused by the value '1027 defined in (%1027 : Float(, 128, *, device=cpu) = onnx::Pad[mode="constant"](%1021, %1026), scope: speakerlab.models.campplus.DTDNN.CAMPPlus::/torch.nn.modules.container.Sequential::xvector/speakerlab.models.campplus.layers.CAMDenseTDNNBlock::block1/speakerlab.models.campplus.layers.CAMDenseTDNNLayer::tdnnd1/speakerlab.models.campplus.layers.CAMLayer::cam_layer )' (type 'Tensor') in the TorchScript graph. The containing node has kind 'onnx::Pad'.]

Inputs:
    #0: 1021 defined in (%1021 : Float(*, 128, *, strides=[6400, 50, 1], requires_grad=0, device=cpu) = onnx::Relu(%input.107), scope: speakerlab.models.campplus.DTDNN.CAMPPlus::/torch.nn.modules.container.Sequential::xvector/speakerlab.models.campplus.layers.CAMDenseTDNNBlock::block1/speakerlab.models.campplus.layers.CAMDenseTDNNLayer::tdnnd1/torch.nn.modules.container.Sequential::nonlinear2/torch.nn.modules.activation.ReLU::relu # /opt/conda/lib/python3.8/site-packages/torch/nn/functional.py:1455:0
)  (type 'Tensor')
    #1: 1026 defined in (%1026 : Long(6, strides=[1], device=cpu) = onnx::Constant[value= 0  0  0  0  0  0 [ CPULongType{6} ]](), scope: speakerlab.models.campplus.DTDNN.CAMPPlus::/torch.nn.modules.container.Sequential::xvector/speakerlab.models.campplus.layers.CAMDenseTDNNBlock::block1/speakerlab.models.campplus.layers.CAMDenseTDNNLayer::tdnnd1/speakerlab.models.campplus.layers.CAMLayer::cam_layer
)  (type 'Tensor')
Outputs:
    #0: 1027 defined in (%1027 : Float(*, 128, *, device=cpu) = onnx::Pad[mode="constant"](%1021, %1026), scope: speakerlab.models.campplus.DTDNN.CAMPPlus::/torch.nn.modules.container.Sequential::xvector/speakerlab.models.campplus.layers.CAMDenseTDNNBlock::block1/speakerlab.models.campplus.layers.CAMDenseTDNNLayer::tdnnd1/speakerlab.models.campplus.layers.CAMLayer::cam_layer
)  (type 'Tensor')

I found this onnx model on release, but i want to train this model with my data. Looking forward to a reply. Thank you

lhanzl avatar Mar 04 '24 07:03 lhanzl