You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.sh 3.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #!/bin/bash
  2. # Copyright 2020 Huawei Technologies Co., Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # ============================================================================
  16. if [ $# -gt 6 ]
  17. then
  18. echo "Usage: sh test.sh [MODEL_PATH] [DATASET] [GROUND_TRUTH_MAT] [SAVE_PATH] [DEVICE_ID] [CKPT]"
  19. echo " or: sh test.sh [MODEL_PATH] [DATASET] [GROUND_TRUTH_MAT] [SAVE_PATH] [DEVICE_ID]"
  20. echo " or: sh test.sh [MODEL_PATH] [DATASET] [GROUND_TRUTH_MAT] [SAVE_PATH]"
  21. echo " or: sh test.sh [MODEL_PATH] [DATASET] [GROUND_TRUTH_MAT]"
  22. echo " or: sh test.sh [MODEL_PATH] [DATASET]"
  23. echo " or: sh test.sh [MODEL_PATH]"
  24. echo " or: sh test.sh "
  25. exit 1
  26. fi
  27. get_real_path(){
  28. if [ "${1:0:1}" == "/" ]; then
  29. echo "$1"
  30. else
  31. echo "$(realpath -m $PWD/$1)"
  32. fi
  33. }
  34. current_exec_path=$(pwd)
  35. echo ${current_exec_path}
  36. dirname_path=$(dirname "$(pwd)")
  37. echo ${dirname_path}
  38. SCRIPT_NAME='test.py'
  39. ulimit -c unlimited
  40. root=${current_exec_path} # your script path
  41. model_path=$root/model/
  42. dataset_root=$root/dataset
  43. dataset_path=$dataset_root/centerface/images/val/images/
  44. ground_truth_mat=$dataset_root/centerface/ground_truth/val.mat
  45. save_path=$root/output/centerface/
  46. device_id=0
  47. ckpt="0-125_24750.ckpt" # the model saved for epoch=125
  48. if [ $# == 1 ]
  49. then
  50. model_path=$(get_real_path $1)
  51. if [ ! -f $model_path ]
  52. then
  53. echo "error: model_path=$model_path is not a file"
  54. exit 1
  55. fi
  56. fi
  57. if [ $# == 2 ]
  58. then
  59. dataset_path=$(get_real_path $2)
  60. if [ ! -f $dataset_path ]
  61. then
  62. echo "error: dataset_path=$dataset_path is not a file"
  63. exit 1
  64. fi
  65. fi
  66. if [ $# == 3 ]
  67. then
  68. ground_truth_mat=$(get_real_path $3)
  69. if [ ! -f $ground_truth_mat ]
  70. then
  71. echo "error: ground_truth_mat=$ground_truth_mat is not a file"
  72. exit 1
  73. fi
  74. fi
  75. if [ $# == 4 ]
  76. then
  77. save_path=$(get_real_path $4)
  78. if [ ! -f $save_path ]
  79. then
  80. echo "error: save_path=$save_path is not a file"
  81. exit 1
  82. fi
  83. fi
  84. if [ $# == 5 ]
  85. then
  86. device_id=$5
  87. fi
  88. if [ $# == 6 ]
  89. then
  90. ckpt=$6
  91. fi
  92. echo $model_path
  93. echo $dataset_path
  94. echo $ground_truth_mat
  95. echo $save_path
  96. export PYTHONPATH=${dirname_path}:$PYTHONPATH
  97. export RANK_SIZE=1
  98. echo 'start testing'
  99. rm -rf ${current_exec_path}/device_test$device_id
  100. echo 'start rank '$device_id
  101. mkdir ${current_exec_path}/device_test$device_id
  102. cd ${current_exec_path}/device_test$device_id || exit
  103. export RANK_ID=0
  104. dev=`expr $device_id + 0`
  105. export DEVICE_ID=$dev
  106. python ${dirname_path}/${SCRIPT_NAME} \
  107. --is_distributed=0 \
  108. --data_dir=$dataset_path \
  109. --test_model=$model_path \
  110. --ground_truth_mat=$ground_truth_mat \
  111. --save_dir=$save_path \
  112. --rank=$device_id \
  113. --ckpt_name=$ckpt > test.log 2>&1 &
  114. echo 'running'