using simple test for multi decode type

pull/883/head
Hui Zhang 4 years ago
parent 4f99dca88e
commit b0e9e88fe0

@ -11,14 +11,8 @@ lmtag=
recog_set="test-clean test-other dev-clean dev-other" recog_set="test-clean test-other dev-clean dev-other"
recog_set="test-clean" recog_set="test-clean"
# bpemode (unigram or bpe) if [ $# != 2 ];then
nbpe=5000 echo "usage: ${0} config_path ckpt_path_prefix"
bpemode=unigram
bpeprefix="data/bpe_${bpemode}_${nbpe}"
bpemodel=${bpeprefix}.model
if [ $# != 3 ];then
echo "usage: ${0} config_path dict_path ckpt_path_prefix"
exit -1 exit -1
fi fi
@ -26,8 +20,7 @@ ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
echo "using $ngpu gpus..." echo "using $ngpu gpus..."
config_path=$1 config_path=$1
dict=$2 ckpt_prefix=$2
ckpt_prefix=$3
chunk_mode=false chunk_mode=false
if [[ ${config_path} =~ ^.*chunk_.*yaml$ ]];then if [[ ${config_path} =~ ^.*chunk_.*yaml$ ]];then
@ -42,46 +35,46 @@ echo "chunk mode ${chunk_mode}"
# exit 1 # exit 1
#fi #fi
pids=() # initialize pids
for dmethd in attention ctc_greedy_search ctc_prefix_beam_search attention_rescoring; do for type in attention ctc_greedy_search; do
( echo "decoding ${type}"
for rtask in ${recog_set}; do if [ ${chunk_mode} == true ];then
( # stream decoding only support batchsize=1
decode_dir=decode_${rtask}_${dmethd}_$(basename ${config_path%.*})_${lmtag}
feat_recog_dir=${datadir}
mkdir -p ${expdir}/${decode_dir}
mkdir -p ${feat_recog_dir}
# split data
split_json.sh ${feat_recog_dir}/manifest.${rtask} ${nj}
#### use CPU for decoding
ngpu=0
# set batchsize 0 to disable batch decoding
batch_size=1 batch_size=1
${decode_cmd} JOB=1:${nj} ${expdir}/${decode_dir}/log/decode.JOB.log \ else
python3 -u ${BIN_DIR}/test.py \ batch_size=64
--nproc ${ngpu} \ fi
--config ${config_path} \ python3 -u ${BIN_DIR}/test.py \
--result_file ${expdir}/${decode_dir}/data.JOB.json \ --nproc ${ngpu} \
--checkpoint_path ${ckpt_prefix} \ --config ${config_path} \
--opts decoding.decoding_method ${dmethd} \ --result_file ${ckpt_prefix}.${type}.rsl \
--opts decoding.batch_size ${batch_size} \ --checkpoint_path ${ckpt_prefix} \
--opts data.test_manifest ${feat_recog_dir}/split${nj}/JOB/manifest.${rtask} --opts decoding.decoding_method ${type} \
--opts decoding.batch_size ${batch_size}
score_sclite.sh --bpe ${nbpe} --bpemodel ${bpemodel}.model --wer true ${expdir}/${decode_dir} ${dict}
if [ $? -ne 0 ]; then
) & echo "Failed in evaluation!"
pids+=($!) # store background pids exit 1
done fi
) & done
pids+=($!) # store background pids
for type in ctc_prefix_beam_search attention_rescoring; do
echo "decoding ${type}"
batch_size=1
python3 -u ${BIN_DIR}/test.py \
--nproc ${ngpu} \
--config ${config_path} \
--result_file ${ckpt_prefix}.${type}.rsl \
--checkpoint_path ${ckpt_prefix} \
--opts decoding.decoding_method ${type} \
--opts decoding.batch_size ${batch_size}
if [ $? -ne 0 ]; then
echo "Failed in evaluation!"
exit 1
fi
done done
i=0; for pid in "${pids[@]}"; do wait ${pid} || ((++i)); done
[ ${i} -gt 0 ] && echo "$0: ${i} background jobs are failed." && false
echo "Finished" echo "Finished"
exit 0 exit 0

Loading…
Cancel
Save