parent
4e94debf69
commit
b15b6c6a26
@ -1,24 +1,23 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
if [ $# != 2 ];then
|
if [ $# != 2 ]; then
|
||||||
echo "usage: ${0} ckpt_dir avg_num"
|
echo "usage: ${0} ckpt_dir avg_num"
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ckpt_path=${1}
|
ckpt_dir=${1}
|
||||||
average_num=${2}
|
average_num=${2}
|
||||||
decode_checkpoint=${ckpt_path}/avg_${average_num}.pdparams
|
decode_checkpoint=${ckpt_dir}/avg_${average_num}.pdparams
|
||||||
|
|
||||||
python3 -u ${MAIN_ROOT}/utils/avg_model.py \
|
python3 -u ${MAIN_ROOT}/utils/avg_model.py \
|
||||||
--dst_model ${decode_checkpoint} \
|
--dst_model ${decode_checkpoint} \
|
||||||
--ckpt_dir ${ckpt_path} \
|
--ckpt_dir ${ckpt_dir} \
|
||||||
--num ${average_num} \
|
--num ${average_num} \
|
||||||
--val_best
|
--val_best
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed in avg ckpt!"
|
echo "Failed in avg ckpt!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1,25 +1,33 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
if [ $# != 1 ];then
|
if [ $# != 2 ];then
|
||||||
echo "usage: ${0} ckpt_tag"
|
echo "usage: CUDA_VISIBLE_DEVICES=0 ${0} config_path ckpt_name"
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p exp
|
|
||||||
|
|
||||||
ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
|
ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
|
||||||
echo "using $ngpu gpus..."
|
echo "using $ngpu gpus..."
|
||||||
|
|
||||||
|
config_path=$1
|
||||||
|
ckpt_name=$2
|
||||||
|
|
||||||
|
device=gpu
|
||||||
|
if [ ngpu == 0 ];then
|
||||||
|
device=cpu
|
||||||
|
fi
|
||||||
|
echo "using ${device}..."
|
||||||
|
|
||||||
|
mkdir -p exp
|
||||||
|
|
||||||
python3 -u ${BIN_DIR}/train.py \
|
python3 -u ${BIN_DIR}/train.py \
|
||||||
--device 'gpu' \
|
--device ${device} \
|
||||||
--nproc ${ngpu} \
|
--nproc ${ngpu} \
|
||||||
--config conf/conformer.yaml \
|
--config ${config_path} \
|
||||||
--output exp/${1}
|
--output exp/${ckpt_name}
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed in training!"
|
echo "Failed in training!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1,19 +1,37 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
source path.sh
|
source path.sh
|
||||||
# only demos
|
|
||||||
|
|
||||||
# prepare data
|
stage=0
|
||||||
bash ./local/data.sh
|
stop_stage=100
|
||||||
|
conf_path=conf/conformer.yaml
|
||||||
|
ckpt=$(basename ${conf_path} | awk -F'.' '{print $1}')
|
||||||
|
avg_num=20
|
||||||
|
avg_ckpt=avg_${avg_num}
|
||||||
|
|
||||||
|
source ${MAIN_ROOT}/utils/parse_options.sh || exit 1;
|
||||||
|
|
||||||
|
if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then
|
||||||
|
# prepare data
|
||||||
|
bash ./local/data.sh || exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
# train model
|
if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then
|
||||||
CUDA_VISIBLE_DEVICES=0,1,2,3 bash ./local/train.sh
|
# train model, all `ckpt` under `exp` dir
|
||||||
|
CUDA_VISIBLE_DEVICES=0,1,2,3 ./local/train.sh ${conf_path} ${ckpt}
|
||||||
|
fi
|
||||||
|
|
||||||
# test model
|
if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
|
||||||
CUDA_VISIBLE_DEVICES=0 bash ./local/test.sh
|
# avg n best model
|
||||||
|
./local/avg.sh exp/${ckpt}/checkpoints ${avg_num}
|
||||||
|
fi
|
||||||
|
|
||||||
# infer model
|
if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
|
||||||
CUDA_VISIBLE_DEVICES=0 bash ./local/infer.sh ckpt/checkpoints/step-3284
|
# test ckpt avg_n
|
||||||
|
CUDA_VISIBLE_DEVICES=4 ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
# export model
|
if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then
|
||||||
bash ./local/export.sh ckpt/checkpoints/step-3284 jit.model
|
# export ckpt avg_n
|
||||||
|
CUDA_VISIBLE_DEVICES= ./local/export.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} exp/${ckpt}/checkpoints/${avg_ckpt}.jit
|
||||||
|
fi
|
||||||
|
Loading…
Reference in new issue