提交 1c9eb445 编写于 作者: H Hui Zhang

onnx opt and check result

上级 7cd40e40
...@@ -34,6 +34,12 @@ def parse_args(): ...@@ -34,6 +34,12 @@ def parse_args():
default=".", default=".",
help="paddle model dir." help="paddle model dir."
) )
parser.add_argument(
'--model_prefix',
type=str,
default="avg_1.jit",
help="paddle model prefix."
)
parser.add_argument( parser.add_argument(
'--onnx_model', '--onnx_model',
type=str, type=str,
...@@ -58,7 +64,7 @@ if __name__ == '__main__': ...@@ -58,7 +64,7 @@ if __name__ == '__main__':
chunk_state_c_box = iodict['chunk_state_c_bos'] chunk_state_c_box = iodict['chunk_state_c_bos']
# paddle # paddle
model = paddle.jit.load(os.path.join(FLAGS.model_dir, "avg_1.jit")) model = paddle.jit.load(os.path.join(FLAGS.model_dir, FLAGS.model_prefix))
res_chunk, res_lens, chunk_state_h, chunk_state_c = model( res_chunk, res_lens, chunk_state_h, chunk_state_c = model(
paddle.to_tensor(audio_chunk), paddle.to_tensor(audio_chunk),
paddle.to_tensor(audio_chunk_lens), paddle.to_tensor(audio_chunk_lens),
......
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
#!/bin/bash #!/bin/bash
set -e
if [ $# != 3 ];then
# ./local/onnx_opt.sh model.old.onnx model.opt.onnx "audio_chunk:1,-1,161 audio_chunk_lens:1 chunk_state_c_box:5,1,1024 chunk_state_h_box:5,1,1024"
echo "usage: $0 onnx.model.in onnx.model.out input_shape "
exit 1
fi
# onnx optimizer # onnx optimizer
onnx-simplifier pip install onnx-simplifier
\ No newline at end of file
in=$1
out=$2
input_shape=$3
check_n=3
onnxsim $in $2 $check_n --dynamic-input-shape --input-shape $input_shape
\ No newline at end of file
文件模式从 100644 更改为 100755
...@@ -53,6 +53,15 @@ fi ...@@ -53,6 +53,15 @@ fi
if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ];then if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ];then
# to onnx # to onnx
./local/tonnx.sh $dir $model $param $exp/model.onnx ./local/tonnx.sh $dir $model $param $exp/model.onnx
./local/infer_check.py --input_file 'static_ds2online_inputs.pickle' --model_dir $dir --onnx_model $exp/model.onnx ./local/infer_check.py --input_file 'static_ds2online_inputs.pickle' --model_dir $dir --onnx_model $exp/model.onnx
fi fi
if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ] ;then
input_shape="audio_chunk:1,-1,161 audio_chunk_lens:1 chunk_state_c_box:5,1,1024 chunk_state_h_box:5,1,1024"
# simplifying onnx model
./local/onnx_opt.sh $exp/model.onnx $exp/model.opt.onnx $input_shape
./local/infer_check.py --input_file 'static_ds2online_inputs.pickle' --model_dir $dir --onnx_model $exp/model.opt.onnx
fi
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册