From 0d57562c99786661fb73e3dad4f2acef75705c4c Mon Sep 17 00:00:00 2001 From: huangjianhui <852142024@qq.com> Date: Thu, 10 Nov 2022 18:53:54 +0800 Subject: [PATCH] [Bug Fix] Fix bugs in release task scripts (#560) * Fix release_task cpp_run.sh Author: felixhjh <852142024@qq.com> Date: Thu Nov 10 07:26:48 2022 +0000 * Add option for infer_ppyoloe.cc author: felixhjh <852142024@qq.com> * Fix bug in release task scripts --- tests/release_task/compare_with_gt.py | 32 +++++++++++++++++---------- tests/release_task/cpp_run.sh | 15 +++++++------ tests/release_task/infer_ppyoloe.cc | 2 +- tests/release_task/py_run.sh | 5 ++++- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/tests/release_task/compare_with_gt.py b/tests/release_task/compare_with_gt.py index 564e74b57..ba030999c 100644 --- a/tests/release_task/compare_with_gt.py +++ b/tests/release_task/compare_with_gt.py @@ -40,7 +40,7 @@ def all_sort(x): y = np.split(x1, len(x1)) z = list(reversed(y)) index = np.lexsort(z) - return x[index] + return np.squeeze(x[index]) def parse_arguments(): @@ -91,8 +91,8 @@ def write2file(error_file): with open(error_file, "a+") as f: from platform import python_version py_version = python_version() - f.write(args.platform + " " + py_version + " " + args.result_path.split( - ".")[0] + "\n") + f.write(args.platform + " " + py_version + " " + + args.result_path.split(".")[0] + "\n") def save_numpy_result(file_path, error_msg): @@ -108,29 +108,37 @@ def check_result(gt_result, infer_result, args): score_diff = diff[:, -2] boxes_diff = diff[:, :-2] boxes_diff_ratio = boxes_diff / (infer_result[:, :-2] + 1e-6) + label_diff_threshold = diff_score_threshold[platform]["label_diff"] + score_diff_threshold = diff_score_threshold[platform]["score_diff"] + boxes_diff_threshold = diff_score_threshold[platform]["boxes_diff"] + boxes_diff_ratio_threshold = diff_score_threshold[platform][ + "boxes_diff_ratio"] is_diff = False backend = args.result_path.split(".")[0] - if (label_diff > diff_score_threshold[platform]["label_diff"]).any(): + if (label_diff > label_diff_threshold).any(): print(args.platform, args.device, "label diff ", label_diff) is_diff = True label_diff_bool_file = args.platform + "_" + backend + "_" + "label_diff_bool.txt" - save_numpy_result(label_diff_bool_file, label_diff > 0) - if (score_diff > diff_score_threshold[platform]["score_diff"]).any(): + save_numpy_result(label_diff_bool_file, + label_diff > label_diff_threshold) + if (score_diff > score_diff_threshold).any(): print(args.platform, args.device, "score diff ", score_diff) is_diff = True score_diff_bool_file = args.platform + "_" + backend + "_" + "score_diff_bool.txt" - save_numpy_result(score_diff_bool_file, score_diff > 1e-4) - if (boxes_diff_ratio > diff_score_threshold[platform]["boxes_diff_ratio"] - ).any() and ( - boxes_diff > diff_score_threshold[platform]["boxes_diff"]).any(): + save_numpy_result(score_diff_bool_file, + score_diff > score_diff_threshold) + if (boxes_diff_ratio > boxes_diff_ratio_threshold).any() and ( + boxes_diff > boxes_diff_threshold).any(): print(args.platform, args.device, "boxes diff ", boxes_diff_ratio) is_diff = True boxes_diff_bool_file = args.platform + "_" + backend + "_" + "boxes_diff_bool.txt" boxes_diff_ratio_file = args.platform + "_" + backend + "_" + "boxes_diff_ratio.txt" boxes_diff_ratio_bool_file = args.platform + "_" + backend + "_" + "boxes_diff_ratio_bool" - save_numpy_result(boxes_diff_bool_file, boxes_diff > 1e-3) + save_numpy_result(boxes_diff_bool_file, + boxes_diff > boxes_diff_threshold) save_numpy_result(boxes_diff_ratio_file, boxes_diff_ratio) - save_numpy_result(boxes_diff_ratio_bool_file, boxes_diff_ratio > 1e-4) + save_numpy_result(boxes_diff_ratio_bool_file, + boxes_diff_ratio > boxes_diff_ratio_threshold) if is_diff: write2file("result.txt") else: diff --git a/tests/release_task/cpp_run.sh b/tests/release_task/cpp_run.sh index 21f1df8bf..e2615194f 100644 --- a/tests/release_task/cpp_run.sh +++ b/tests/release_task/cpp_run.sh @@ -48,14 +48,14 @@ tar xvf $CPP_FASTDEPLOY_PACKAGE.tgz mkdir build && cd build cmake .. -DFASTDEPLOY_INSTALL_DIR=${PWD}/../$CPP_FASTDEPLOY_PACKAGE -DCMAKE_CXX_COMPILER=$CMAKE_CXX_COMPILER make -j - +ret=0 for((i=0;i> cpp_cpu_result.txt - python $COMPARE_SHELL --gt_path $GROUND_TRUTH_PATH --result_path cpp_cpu_result.txt --platform $PLATFORM --device cpu --conf_threshold $CONF_THRESHOLD + ./infer_ppyoloe_demo --model_dir=$MODEL_PATH --image_file=$IMAGE_PATH --device=cpu --backend=$backend >> cpp_$backend\_cpu_result.txt + python $COMPARE_SHELL --gt_path $GROUND_TRUTH_PATH --result_path cpp_$backend\_cpu_result.txt --platform $PLATFORM --device cpu --conf_threshold $CONF_THRESHOLD fi if [ "$DEVICE" = "gpu" ];then @@ -63,14 +63,15 @@ do ./infer_ppyoloe_demo --model_dir=$MODEL_PATH --image_file=$IMAGE_PATH --device=gpu --backend=$backend >> cpp_trt_result.txt python $COMPARE_SHELL --gt_path $GROUND_TRUTH_PATH --result_path cpp_trt_result.txt --platform $PLATFORM --device trt --conf_threshold $CONF_THRESHOLD else - ./infer_ppyoloe_demo --model_dir=$MODEL_PATH --image_file=$IMAGE_PATH --device=gpu --backend=$backend >> cpp_gpu_result.txt - python $COMPARE_SHELL --gt_path $GROUND_TRUTH_PATH --result_path cpp_gpu_result.txt --platform $PLATFORM --device gpu --conf_threshold $CONF_THRESHOLD + ./infer_ppyoloe_demo --model_dir=$MODEL_PATH --image_file=$IMAGE_PATH --device=gpu --backend=$backend >> cpp_$backend\_gpu_result.txt + python $COMPARE_SHELL --gt_path $GROUND_TRUTH_PATH --result_path cpp_$backend\_gpu_result.txt --platform $PLATFORM --device gpu --conf_threshold $CONF_THRESHOLD fi fi + if [ $? -ne 0 ];then + ret=-1 + fi done -ret=$? - res_file="result.txt" if [ ! -f $res_file ];then if [ $ret -ne 0 ];then diff --git a/tests/release_task/infer_ppyoloe.cc b/tests/release_task/infer_ppyoloe.cc index 70ab5e71f..e70453367 100644 --- a/tests/release_task/infer_ppyoloe.cc +++ b/tests/release_task/infer_ppyoloe.cc @@ -54,7 +54,7 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) { return; } auto model = fastdeploy::vision::detection::PPYOLOE(model_file, params_file, - config_file); + config_file, option); if (!model.Initialized()) { std::cerr << "Failed to initialize." << std::endl; return; diff --git a/tests/release_task/py_run.sh b/tests/release_task/py_run.sh index 366242463..2a4f73f16 100644 --- a/tests/release_task/py_run.sh +++ b/tests/release_task/py_run.sh @@ -41,6 +41,7 @@ fi case_number=${#RUN_CASE[@]} py_version=$(python -V | awk '{print $2}') echo "py_version:" $py_version +ret=0 for((j=0;j