From c693bb0829c89469bd16ea3d797fa0beb6f7d46b Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Sun, 25 Apr 2021 07:49:32 +0000 Subject: [PATCH] fix log, add avg script --- deepspeech/exps/u2/model.py | 2 +- examples/aishell/s1/conf/conformer.yaml | 2 +- examples/aishell/s1/local/avg.sh | 24 ++++++++++++++++++++++++ examples/aishell/s1/local/export.sh | 4 ++-- examples/aishell/s1/local/test.sh | 16 +++++++++++----- examples/aishell/s1/local/train.sh | 5 +++++ 6 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 examples/aishell/s1/local/avg.sh diff --git a/deepspeech/exps/u2/model.py b/deepspeech/exps/u2/model.py index 2fee8ded6..5b1ed7e40 100644 --- a/deepspeech/exps/u2/model.py +++ b/deepspeech/exps/u2/model.py @@ -136,7 +136,7 @@ class U2Trainer(Trainer): msg = f"Valid: Rank: {dist.get_rank()}, " msg += "epoch: {}, ".format(self.epoch) msg += "step: {}, ".format(self.iteration) - msg += "batch : {}/{}, ".format(i + 1, len(self.valid_loader)) + msg += "batch: {}/{}, ".format(i + 1, len(self.valid_loader)) msg += ', '.join('{}: {:>.6f}'.format(k, v) for k, v in valid_dump.items()) logger.info(msg) diff --git a/examples/aishell/s1/conf/conformer.yaml b/examples/aishell/s1/conf/conformer.yaml index 66e0228f8..e80d08722 100644 --- a/examples/aishell/s1/conf/conformer.yaml +++ b/examples/aishell/s1/conf/conformer.yaml @@ -90,7 +90,7 @@ training: decoding: batch_size: 16 - error_rate_type: wer + error_rate_type: cer decoding_method: attention # 'attention', 'ctc_greedy_search', 'ctc_prefix_beam_search', 'attention_rescoring' lang_model_path: data/lm/common_crawl_00.prune01111.trie.klm alpha: 2.5 diff --git a/examples/aishell/s1/local/avg.sh b/examples/aishell/s1/local/avg.sh new file mode 100644 index 000000000..7e2befee6 --- /dev/null +++ b/examples/aishell/s1/local/avg.sh @@ -0,0 +1,24 @@ +#! /usr/bin/env bash + +if [ $# != 2 ];then + echo "usage: ${0} ckpt_path avg_num" + exit -1 +fi + +ckpt_path=${1} +average_num=${2} +decode_checkpoint=${ckpt_path}/avg_${average_num}.pt + +python3 -u ${MAIN_ROOT}/utils/avg_model.py \ +--dst_model ${decode_checkpoint} \ +--ckpt_dir ${ckpt_path} \ +--num ${average_num} \ +--val_best + +if [ $? -ne 0 ]; then + echo "Failed in avg ckpt!" + exit 1 +fi + + +exit 0 \ No newline at end of file diff --git a/examples/aishell/s1/local/export.sh b/examples/aishell/s1/local/export.sh index 864ecb2d5..974575eb4 100644 --- a/examples/aishell/s1/local/export.sh +++ b/examples/aishell/s1/local/export.sh @@ -1,7 +1,7 @@ #! /usr/bin/env bash if [ $# != 2 ];then - echo "usage: export ckpt_path jit_model_path" + echo "usage: ${0} ckpt_path jit_model_path" exit -1 fi @@ -12,7 +12,7 @@ python3 -u ${BIN_DIR}/export.py \ if [ $? -ne 0 ]; then - echo "Failed in evaluation!" + echo "Failed in export!" exit 1 fi diff --git a/examples/aishell/s1/local/test.sh b/examples/aishell/s1/local/test.sh index e4cf0c85d..01aefc63e 100644 --- a/examples/aishell/s1/local/test.sh +++ b/examples/aishell/s1/local/test.sh @@ -1,16 +1,22 @@ #! /usr/bin/env bash -# download language model -bash local/download_lm_ch.sh -if [ $? -ne 0 ]; then - exit 1 +if [ $# != 1 ];then + echo "usage: ${0} ckpt_path" + exit -1 fi +# download language model +#bash local/download_lm_ch.sh +#if [ $? -ne 0 ]; then +# exit 1 +#fi + python3 -u ${BIN_DIR}/test.py \ --device 'gpu' \ --nproc 1 \ --config conf/conformer.yaml \ ---output ckpt +--result_file ${1}.rsl \ +--checkpoint_path ${1} if [ $? -ne 0 ]; then echo "Failed in evaluation!" diff --git a/examples/aishell/s1/local/train.sh b/examples/aishell/s1/local/train.sh index 0f032fa74..afa550baa 100644 --- a/examples/aishell/s1/local/train.sh +++ b/examples/aishell/s1/local/train.sh @@ -1,5 +1,10 @@ #! /usr/bin/env bash +if [ $# != 1 ];then + echo "usage: ${0} ckpt_tag" + exit -1 +fi + ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..."