searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

语音系列-wenet之pytorch模型导出为Onnx模型后结果前后不一致

2024-06-26 09:44:34
4
0

使用comformer模型训练了一个粤语语音识别模型,后面使用export_onnx_gpu.py将pytorch模型导出为Onnx模型,两个模型识别结果相差很大,Onnx模型结果明显要差

看到github也有人提出相同的issue,但是没有解决方法。后来一点点比对pt和onnx的输出,最终找到差距是推理代码的 eossos的id被固定为len(vocab) - 1

#wenet/runtime/gpu/model\_repo/scoring/1/model.py
sos = eos = len(vocab) - 1 # 这里应该改为sos = eos =2
#wenet/bin/recognize\_onnx\_gpu.py
eos = sos = len(char\_dict) - 1 # 这里应该改为sos = eos =2

因为build dict的时候 echo "<sos/eos> 2" >> \$dict 直接固化为2了

if [ \${stage} -le 2 ] && [ \${stop\_stage} -ge 2 ]; then
echo "Make a dictionary"
mkdir -p \$(dirname \$dict)
echo " 0" > \${dict} # 0 is for "blank" in CTC
echo " 1" >> \${dict} # must be 1
echo "<sos/eos> 2" >> \$dict
0条评论
0 / 1000