You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
973 B
41 lines
973 B
3 years ago
|
#!/bin/bash
|
||
|
set -e
|
||
|
|
||
3 years ago
|
if [ $# -ne 4 ]; then
|
||
|
echo "usage: bash ./run.sh stage gpu train_config avg_num"
|
||
|
echo "eg: bash ./run.sh 1 0 train_config 1"
|
||
3 years ago
|
exit -1
|
||
|
fi
|
||
|
|
||
|
stage=$1
|
||
|
stop_stage=100
|
||
|
gpus=$2
|
||
|
conf_path=$3
|
||
|
avg_num=$4
|
||
|
avg_ckpt=avg_${avg_num}
|
||
|
ckpt=$(basename ${conf_path} | awk -F'.' '{print $1}')
|
||
3 years ago
|
log_dir=log
|
||
|
|
||
|
source path.sh ${ckpt}
|
||
3 years ago
|
|
||
|
|
||
|
if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then
|
||
3 years ago
|
# prepare data
|
||
|
bash ./local/data.sh
|
||
3 years ago
|
fi
|
||
|
|
||
|
if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
|
||
3 years ago
|
# train model, all `ckpt` under `exp` dir
|
||
|
CUDA_VISIBLE_DEVICES=${gpus} bash ./local/train.sh ${conf_path} ${ckpt} ${log_dir}
|
||
|
fi
|
||
|
|
||
|
if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
|
||
3 years ago
|
# avg n best model
|
||
|
bash ./local/avg.sh exp/${ckpt}/checkpoints ${avg_num}
|
||
|
fi
|
||
|
|
||
3 years ago
|
if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then
|
||
|
# test ckpt avg_n
|
||
3 years ago
|
CUDA_VISIBLE_DEVICES=${gpus} bash ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1
|
||
|
fi
|