build_mar.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. # vim /usr/local/lib/python3.6/dist-packages/model_archiver/model_packaging_utils.py
  3. #--------------------------------------------------------------
  4. #====================== 1. set config_files file ==================
  5. #--------------------------------------------------------------
  6. # shellcheck disable=SC2006
  7. # shellcheck disable=SC2030
  8. # shellcheck disable=SC2046
  9. #py_files=`find $(pwd)/ -type f -name "*.py"` &&
  10. export_path="models-server/model-store" &&
  11. #for var in ${py_files}
  12. #do
  13. # export_paths_str="${var},${export_paths_str}"
  14. #done
  15. #export_paths_str=${export_paths_str%?}
  16. #echo {"$export_paths_str"}
  17. if [ -d "$export_path" ]; then
  18. rm -rf "$export_path" && mkdir -p "$export_path"
  19. else
  20. mkdir -p "$export_path"
  21. fi
  22. if [ ! -d "$export_path" ]; then
  23. mkdir -p "$export_path"
  24. fi
  25. #--------------------------------------------------------------
  26. #===================== 2. Generate Mar File ==================
  27. #--------------------------------------------------------------
  28. # note delete __pycache__
  29. rm -rf ./src/__pycache__
  30. torch-model-archiver \
  31. --model-name yolov5 \
  32. --version 1.0 \
  33. --serialized-file ./models_zoo/yolov5_model_zoo/yolov5x.pt \
  34. --handler src/object_detector_handler.py \
  35. --force \
  36. --extra-files ../src_code \
  37. --export-path "$export_path" \
  38. --requirements-file requirements.txt
  39. #--------------------------------------------------------------
  40. #================ 3. Generate Properties File ================
  41. #--------------------------------------------------------------
  42. echo "inference_address=http://0.0.0.0:8080" > ./models-server/model-store/yolov5_config.properties &&
  43. echo "management_address=http://0.0.0.0:8081" >> ./models-server/model-store/yolov5_config.properties &&
  44. echo "metrics_address=http://0.0.0.0:8082" >> ./models-server/model-store/yolov5_config.properties &&
  45. echo "max_request_size=878837280" >> ./models-server/model-store/yolov5_config.properties &&
  46. echo "install_py_dep_per_model=true" >> ./models-server/model-store/yolov5_config.properties
  47. #--------------------------------------------------------------
  48. #============= 3. Generate Log Properties File ===============
  49. #--------------------------------------------------------------
  50. cp ./config_files/yolov5_log4j2.xml ./models-server/model-store