#!/usr/bin/env python
data_path=$1
resume_path=$2
ASCEND_DEVICE_ID=0
RANK_ID=0
if [ $# != 2 ]
then
echo "Usage: bash ./test/eval_8p.sh ./inputs/dsb2018_96/ ./models/dsb2018_96_NestedUNet_woDS/model_best.pth.tar"
exit 1
fi
if [ ! -f $resume_path ]
then
echo "error: resume_path=$resume_path is not a file"
exit 1
fi
cur_path=`pwd`
cur_path_last_dirname=${cur_path##*/}
if [ x"${cur_path_last_dirname}" == x"test" ];then
test_path_dir=${cur_path}
cd ..
cur_path=`pwd`
else
test_path_dir=${cur_path}/test
fi
cd $cur_path
start_time=$(date +%s)
check_etp_flag=`env | grep etp_running_flag`
etp_flag=`echo ${check_etp_flag#*=}`
if [ x"${etp_flag}" != x"true" ];then
source ./test/env_npu.sh
fi
nohup python3 -u train.py \
--data_path ${data_path} \
--device npu \
--batch_size 128 \
--num_gpus 1 \
--num_workers 16 \
--evaluate \
--resume ${resume_path} \
--rank_id $RANK_ID > ${test_path_dir}/output/${ASCEND_DEVICE_ID}/eval.log 2>&1 &
wait
end_time=$(date +%s)
e2e_time=$(( $end_time - $start_time ))
echo "------------------ Final result ------------------"
eval_accuracy=`grep -a 'AVG' ${test_path_dir}/output/${ASCEND_DEVICE_ID}/eval.log|awk -F " " '{print $8}'|awk 'END {print}'`
echo "Final eval Accuracy : ${eval_accuracy}"
echo "E2E eval Duration sec : $e2e_time"