modelscope / 3D-Speaker

A Repository for Single- and Multi-modal Speaker Verification, Speaker Recognition and Speaker Diarization
Apache License 2.0
1.09k stars 95 forks source link

onnx模型导出报错 #136

Open Square-of-W opened 1 week ago

Square-of-W commented 1 week ago

使用speakerlab/bin下的onnx导出脚本将cam++模型导出onnx模型 python speakerlab/bin/export_speaker_embedding_onnx.py \ --experiment_path pretrained/speech_campplus_sv_zh-cn_16k-common \ --model_id iic/speech_campplus_sv_zh-cn_16k-common \ --target_onnx_file ./pretrained/speech_campplus_sv_zh-cn_16k-common/onnx_modle

出现下述报错: 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 '1026 defined in (%1026 : Float(, 128, , device=cpu) = onnx::Pad[mode="constant"](%1020, %1025), 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: 1020 defined in (%1020 : Float(*, 128, *, strides=[22144, 173, 1], requires_grad=1, 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 # /home/yueya/.local/lib/python3.8/site-packages/torch/nn/functional.py:1455:0
)  (type 'Tensor')
    #1: 1025 defined in (%1025 : 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: 1026 defined in (%1026 : Float(*, 128, *, device=cpu) = onnx::Pad[mode="constant"](%1020, %1025), 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')
GeekOrangeLuYao commented 4 days ago

Could you provide more information? We do not find any problems when running your scripts:

python speakerlab/bin/export_speaker_embedding_onnx.py --experiment_path pretrained/speech_campplus_sv_zh-cn_16k-common --model_id iic/speech_campplus_sv_zh-cn_16k-common --target_onnx_file ./pretrained/speech_campplus_sv_zh-cn_16k-common/onnx_modle

And it create a file called onnx_modle under pretrained/speech_campplus_sv_zh-cn_16k-common/.

We have the following version information for you:

onnx 1.14.1
onnxruntime 1.16.1
torch 2.4.0