prepare.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #!/bin/bash
  2. source test_tipc/utils_func.sh
  3. FILENAME=$1
  4. # MODE be one of ['lite_train_lite_infer' 'lite_train_whole_infer'
  5. # 'whole_train_whole_infer', 'whole_infer', 'klquant_whole_infer',
  6. # 'cpp_infer', 'serving_infer', 'lite_infer', 'paddle2onnx_infer']
  7. MODE=$2
  8. # parse params
  9. dataline=$(cat ${FILENAME})
  10. IFS=$'\n'
  11. lines=(${dataline})
  12. # The training params
  13. model_name=$(func_parser_value "${lines[1]}")
  14. python=$(func_parser_value "${lines[2]}")
  15. if [ ${MODE} = "whole_train_whole_infer" ];then
  16. mv ./dataset/coco/download_coco.py . && rm -rf ./dataset/coco/* && mv ./download_coco.py ./dataset/coco/
  17. # prepare whole training data
  18. eval "${python} ./dataset/coco/download_coco.py"
  19. elif [ ${MODE} = "cpp_infer" ];then
  20. # download coco lite data
  21. wget -nc -P ./dataset/coco/ https://paddledet.bj.bcebos.com/data/tipc/coco_tipc.tar --no-check-certificate
  22. cd ./dataset/coco/ && tar -xvf coco_tipc.tar && mv -n coco_tipc/* .
  23. rm -rf coco_tipc/ && cd ../../
  24. # download wider_face lite data
  25. wget -nc -P ./dataset/wider_face/ https://paddledet.bj.bcebos.com/data/tipc/wider_tipc.tar --no-check-certificate
  26. cd ./dataset/wider_face/ && tar -xvf wider_tipc.tar && mv -n wider_tipc/* .
  27. rm -rf wider_tipc/ && cd ../../
  28. # download spine lite data
  29. wget -nc -P ./dataset/spine_coco/ https://paddledet.bj.bcebos.com/data/tipc/spine_tipc.tar --no-check-certificate
  30. cd ./dataset/spine_coco/ && tar -xvf spine_tipc.tar && mv -n spine_tipc/* .
  31. rm -rf spine_tipc/ && cd ../../
  32. if [[ ${model_name} =~ "s2anet" ]]; then
  33. cd ./ppdet/ext_op && eval "${python} setup.py install"
  34. cd ../../
  35. elif [[ ${model_name} =~ "tinypose" ]]; then
  36. wget -nc -P ./output_inference/ https://bj.bcebos.com/v1/paddledet/models/keypoint/picodet_s_320_pedestrian.tar --no-check-certificate
  37. cd ./output_inference/ && tar -xvf picodet_s_320_pedestrian.tar
  38. cd ../
  39. fi
  40. # download KL model
  41. if [[ ${model_name} = "picodet_lcnet_1_5x_416_coco_KL" ]]; then
  42. wget -nc -P ./output_inference/picodet_lcnet_1_5x_416_coco_KL/ https://bj.bcebos.com/v1/paddledet/data/tipc/models/picodet_lcnet_1_5x_416_coco_ptq.tar --no-check-certificate
  43. cd ./output_inference/picodet_lcnet_1_5x_416_coco_KL/ && tar -xvf picodet_lcnet_1_5x_416_coco_ptq.tar && mv -n picodet_lcnet_1_5x_416_coco_ptq/* .
  44. cd ../../
  45. elif [[ ${model_name} = "ppyoloe_crn_s_300e_coco_KL" ]]; then
  46. wget -nc -P ./output_inference/ppyoloe_crn_s_300e_coco_KL/ https://bj.bcebos.com/v1/paddledet/data/tipc/models/ppyoloe_crn_s_300e_coco_ptq.tar --no-check-certificate
  47. cd ./output_inference/ppyoloe_crn_s_300e_coco_KL/ && tar -xvf ppyoloe_crn_s_300e_coco_ptq.tar && mv -n ppyoloe_crn_s_300e_coco_ptq/* .
  48. cd ../../
  49. elif [[ ${model_name} = "ppyolo_mbv3_large_coco_KL" ]]; then
  50. wget -nc -P ./output_inference/ppyolo_mbv3_large_coco_KL/ https://bj.bcebos.com/v1/paddledet/data/tipc/models/ppyolo_mbv3_large_ptq.tar --no-check-certificate
  51. cd ./output_inference/ppyolo_mbv3_large_coco_KL/ && tar -xvf ppyolo_mbv3_large_ptq.tar && mv -n ppyolo_mbv3_large_ptq/* .
  52. cd ../../
  53. elif [[ ${model_name} = "mask_rcnn_r50_fpn_1x_coco_KL" ]]; then
  54. wget -nc -P ./output_inference/mask_rcnn_r50_fpn_1x_coco_KL/ https://bj.bcebos.com/v1/paddledet/data/tipc/models/mask_rcnn_r50_fpn_1x_coco_ptq.tar --no-check-certificate
  55. cd ./output_inference/mask_rcnn_r50_fpn_1x_coco_KL/ && tar -xvf mask_rcnn_r50_fpn_1x_coco_ptq.tar && mv -n mask_rcnn_r50_fpn_1x_coco_ptq/* .
  56. cd ../../
  57. elif [[ ${model_name} = "tinypose_128x96_KL" ]]; then
  58. wget -nc -P ./output_inference/tinypose_128x96_KL/ https://bj.bcebos.com/v1/paddledet/data/tipc/models/tinypose_128x96_ptq.tar --no-check-certificate
  59. cd ./output_inference/tinypose_128x96_KL/ && tar -xvf tinypose_128x96_ptq.tar && mv -n tinypose_128x96_ptq/* .
  60. cd ../../
  61. fi
  62. # download mot lite data
  63. wget -nc -P ./dataset/mot/ https://paddledet.bj.bcebos.com/data/tipc/mot_tipc.tar --no-check-certificate
  64. cd ./dataset/mot/ && tar -xvf mot_tipc.tar && mv -n mot_tipc/* .
  65. rm -rf mot_tipc/ && cd ../../
  66. opencv_dir=$(func_parser_value "${lines[15]}")
  67. # prepare opencv
  68. cd ./deploy/cpp
  69. if [ ${opencv_dir} = "default" ] || [ ${opencv_dir} = "null" ]; then
  70. if [ -d "deps/opencv-3.4.16_gcc8.2_ffmpeg/" ]; then
  71. echo "################### Opencv already exists, skip downloading. ###################"
  72. else
  73. mkdir -p $(pwd)/deps && cd $(pwd)/deps
  74. wget -c https://paddledet.bj.bcebos.com/data/opencv-3.4.16_gcc8.2_ffmpeg.tar.gz --no-check-certificate
  75. tar -xvf opencv-3.4.16_gcc8.2_ffmpeg.tar.gz && cd ../
  76. echo "################### Finish downloading opencv. ###################"
  77. fi
  78. fi
  79. cd ../../
  80. elif [ ${MODE} = "benchmark_train" ];then
  81. pip install -U pip
  82. pip install Cython
  83. pip install -r requirements.txt
  84. if [[ ${model_name} =~ "higherhrnet" ]] || [[ ${model_name} =~ "hrnet" ]] || [[ ${model_name} =~ "tinypose" ]];then
  85. wget -nc -P ./dataset/ https://bj.bcebos.com/v1/paddledet/data/coco.tar --no-check-certificate
  86. cd ./dataset/ && tar -xf coco.tar
  87. ls ./coco/
  88. cd ../
  89. elif [[ ${model_name} =~ "ppyoloe_r_crn_s_3x_spine_coco" ]];then
  90. wget -nc -P ./dataset/spine_coco/ https://paddledet.bj.bcebos.com/data/tipc/spine_coco_tipc.tar --no-check-certificate
  91. cd ./dataset/spine_coco/ && tar -xvf spine_coco_tipc.tar && mv -n spine_coco_tipc/* .
  92. rm -rf spine_coco_tipc/ && cd ../../
  93. cd ./ppdet/ext_op && eval "${python} setup.py install"
  94. cd ../../
  95. else
  96. # prepare lite benchmark coco data
  97. wget -nc -P ./dataset/coco/ https://paddledet.bj.bcebos.com/data/coco_benchmark.tar --no-check-certificate
  98. cd ./dataset/coco/ && tar -xf coco_benchmark.tar
  99. mv -u coco_benchmark/* ./
  100. ls ./
  101. cd ../../
  102. # prepare lite benchmark mot data
  103. wget -nc -P ./dataset/mot/ https://paddledet.bj.bcebos.com/data/mot_benchmark.tar --no-check-certificate
  104. cd ./dataset/mot/ && tar -xf mot_benchmark.tar
  105. mv -u mot_benchmark/* ./
  106. ls ./
  107. cd ../../
  108. fi
  109. elif [ ${MODE} = "paddle2onnx_infer" ];then
  110. # install paddle2onnx
  111. ${python} -m pip install paddle2onnx
  112. ${python} -m pip install onnx onnxruntime
  113. elif [ ${MODE} = "serving_infer" ];then
  114. unset https_proxy http_proxy
  115. # download coco lite data
  116. wget -nc -P ./dataset/coco/ https://paddledet.bj.bcebos.com/data/tipc/coco_tipc.tar --no-check-certificate
  117. cd ./dataset/coco/ && tar -xvf coco_tipc.tar && mv -n coco_tipc/* .
  118. rm -rf coco_tipc/ && cd ../../
  119. # download KL model
  120. if [[ ${model_name} = "picodet_lcnet_1_5x_416_coco_KL" ]]; then
  121. wget -nc -P ./output_inference/picodet_lcnet_1_5x_416_coco_KL/ https://bj.bcebos.com/v1/paddledet/data/tipc/models/picodet_lcnet_1_5x_416_coco_ptq.tar --no-check-certificate
  122. cd ./output_inference/picodet_lcnet_1_5x_416_coco_KL/ && tar -xvf picodet_lcnet_1_5x_416_coco_ptq.tar && mv -n picodet_lcnet_1_5x_416_coco_ptq/* .
  123. cd ../../
  124. eval "${python} -m paddle_serving_client.convert --dirname output_inference/picodet_lcnet_1_5x_416_coco_KL/ --model_filename model.pdmodel --params_filename model.pdiparams --serving_server output_inference/picodet_lcnet_1_5x_416_coco_KL/serving_server --serving_client output_inference/picodet_lcnet_1_5x_416_coco_KL/serving_client"
  125. elif [[ ${model_name} = "ppyoloe_crn_s_300e_coco_KL" ]]; then
  126. wget -nc -P ./output_inference/ppyoloe_crn_s_300e_coco_KL/ https://bj.bcebos.com/v1/paddledet/data/tipc/models/ppyoloe_crn_s_300e_coco_ptq.tar --no-check-certificate
  127. cd ./output_inference/ppyoloe_crn_s_300e_coco_KL/ && tar -xvf ppyoloe_crn_s_300e_coco_ptq.tar && mv -n ppyoloe_crn_s_300e_coco_ptq/* .
  128. cd ../../
  129. eval "${python} -m paddle_serving_client.convert --dirname output_inference/ppyoloe_crn_s_300e_coco_KL/ --model_filename model.pdmodel --params_filename model.pdiparams --serving_server output_inference/ppyoloe_crn_s_300e_coco_KL/serving_server --serving_client output_inference/ppyoloe_crn_s_300e_coco_KL/serving_client"
  130. elif [[ ${model_name} = "ppyolo_mbv3_large_coco_KL" ]]; then
  131. wget -nc -P ./output_inference/ppyolo_mbv3_large_coco_KL/ https://bj.bcebos.com/v1/paddledet/data/tipc/models/ppyolo_mbv3_large_ptq.tar --no-check-certificate
  132. cd ./output_inference/ppyolo_mbv3_large_coco_KL/ && tar -xvf ppyolo_mbv3_large_ptq.tar && mv -n ppyolo_mbv3_large_ptq/* .
  133. cd ../../
  134. eval "${python} -m paddle_serving_client.convert --dirname output_inference/ppyolo_mbv3_large_coco_KL/ --model_filename model.pdmodel --params_filename model.pdiparams --serving_server output_inference/ppyolo_mbv3_large_coco_KL/serving_server --serving_client output_inference/ppyolo_mbv3_large_coco_KL/serving_client"
  135. elif [[ ${model_name} = "mask_rcnn_r50_fpn_1x_coco_KL" ]]; then
  136. wget -nc -P ./output_inference/mask_rcnn_r50_fpn_1x_coco_KL/ https://bj.bcebos.com/v1/paddledet/data/tipc/models/mask_rcnn_r50_fpn_1x_coco_ptq.tar --no-check-certificate
  137. cd ./output_inference/mask_rcnn_r50_fpn_1x_coco_KL/ && tar -xvf mask_rcnn_r50_fpn_1x_coco_ptq.tar && mv -n mask_rcnn_r50_fpn_1x_coco_ptq/* .
  138. cd ../../
  139. eval "${python} -m paddle_serving_client.convert --dirname output_inference/mask_rcnn_r50_fpn_1x_coco_KL/ --model_filename model.pdmodel --params_filename model.pdiparams --serving_server output_inference/mask_rcnn_r50_fpn_1x_coco_KL/serving_server --serving_client output_inference/mask_rcnn_r50_fpn_1x_coco_KL/serving_client"
  140. elif [[ ${model_name} = "tinypose_128x96_KL" ]]; then
  141. wget -nc -P ./output_inference/tinypose_128x96_KL/ https://bj.bcebos.com/v1/paddledet/data/tipc/models/tinypose_128x96_ptq.tar --no-check-certificate
  142. cd ./output_inference/tinypose_128x96_KL/ && tar -xvf tinypose_128x96_ptq.tar && mv -n tinypose_128x96_ptq/* .
  143. cd ../../
  144. eval "${python} -m paddle_serving_client.convert --dirname output_inference/tinypose_128x96_KL/ --model_filename model.pdmodel --params_filename model.pdiparams --serving_server output_inference/tinypose_128x96_KL/serving_server --serving_client output_inference/tinypose_128x96_KL/serving_client"
  145. fi
  146. else
  147. # download coco lite data
  148. wget -nc -P ./dataset/coco/ https://paddledet.bj.bcebos.com/data/tipc/coco_tipc.tar --no-check-certificate
  149. cd ./dataset/coco/ && tar -xvf coco_tipc.tar && mv -n coco_tipc/* .
  150. rm -rf coco_tipc/ && cd ../../
  151. # download wider_face lite data
  152. wget -nc -P ./dataset/wider_face/ https://paddledet.bj.bcebos.com/data/tipc/wider_tipc.tar --no-check-certificate
  153. cd ./dataset/wider_face/ && tar -xvf wider_tipc.tar && mv -n wider_tipc/* .
  154. rm -rf wider_tipc/ && cd ../../
  155. # download spine_coco lite data
  156. wget -nc -P ./dataset/spine_coco/ https://paddledet.bj.bcebos.com/data/tipc/spine_coco_tipc.tar --no-check-certificate
  157. cd ./dataset/spine_coco/ && tar -xvf spine_coco_tipc.tar && mv -n spine_coco_tipc/* .
  158. rm -rf spine_coco_tipc/ && cd ../../
  159. if [[ ${model_name} =~ "s2anet" ]]; then
  160. cd ./ppdet/ext_op && eval "${python} setup.py install"
  161. cd ../../
  162. elif [[ ${model_name} =~ "ppyoloe_r_crn_s_3x_spine_coco" ]]; then
  163. cd ./ppdet/ext_op && eval "${python} setup.py install"
  164. cd ../../
  165. elif [[ ${model_name} =~ "fcosr_x50_3x_spine_coco" ]]; then
  166. cd ./ppdet/ext_op && eval "${python} setup.py install"
  167. cd ../../
  168. fi
  169. # download mot lite data
  170. wget -nc -P ./dataset/mot/ https://paddledet.bj.bcebos.com/data/tipc/mot_tipc.tar --no-check-certificate
  171. cd ./dataset/mot/ && tar -xvf mot_tipc.tar && mv -n mot_tipc/* .
  172. rm -rf mot_tipc/ && cd ../../
  173. fi