test.sh 1.5 KB
Newer Older
1
#!/bin/bash
2 3 4 5 6 7 8 9 10 11 12 13

if [ $# != 2 ];then
    echo "usage: ${0} config_path ckpt_path_prefix"
    exit -1
fi

ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
echo "using $ngpu gpus..."

config_path=$1
ckpt_prefix=$2

14
chunk_mode=false
H
Hui Zhang 已提交
15
if [[ ${config_path} =~ ^.*chunk_.*yaml$ ]];then
16 17
    chunk_mode=true
fi
H
Hui Zhang 已提交
18

19 20 21 22 23 24 25
# download language model
#bash local/download_lm_ch.sh
#if [ $? -ne 0 ]; then
#    exit 1
#fi


H
Hui Zhang 已提交
26 27
for type in attention ctc_greedy_search; do
    echo "decoding ${type}"
28 29 30 31 32 33
    if [ ${chunk_mode} == true ];then
        # stream decoding only support batchsize=1
        batch_size=1
    else
        batch_size=64
    fi
H
Hui Zhang 已提交
34 35
    output_dir=${ckpt_prefix}
    mkdir -p ${output_dir}
H
Hui Zhang 已提交
36
    python3 -u ${BIN_DIR}/test.py \
H
Hui Zhang 已提交
37
    --nproc ${ngpu} \
H
Hui Zhang 已提交
38
    --config ${config_path} \
H
Hui Zhang 已提交
39
    --result_file ${output_dir}/${type}.rsl \
H
Hui Zhang 已提交
40 41 42 43 44 45 46 47 48 49 50 51
    --checkpoint_path ${ckpt_prefix} \
    --opts decoding.decoding_method ${type} decoding.batch_size ${batch_size}

    if [ $? -ne 0 ]; then
        echo "Failed in evaluation!"
        exit 1
    fi
done

for type in ctc_prefix_beam_search attention_rescoring; do
    echo "decoding ${type}"
    batch_size=1
H
Hui Zhang 已提交
52 53
    output_dir=${ckpt_prefix}
    mkdir -p ${output_dir}
H
Hui Zhang 已提交
54
    python3 -u ${BIN_DIR}/test.py \
H
Hui Zhang 已提交
55
    --nproc ${ngpu} \
H
Hui Zhang 已提交
56
    --config ${config_path} \
H
Hui Zhang 已提交
57
    --result_file ${output_dir}/${type}.rsl \
H
Hui Zhang 已提交
58 59 60 61 62 63 64 65
    --checkpoint_path ${ckpt_prefix} \
    --opts decoding.decoding_method ${type} decoding.batch_size ${batch_size}

    if [ $? -ne 0 ]; then
        echo "Failed in evaluation!"
        exit 1
    fi
done
66 67

exit 0