coreml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. set -e
  3. pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
  4. case "${OSTYPE}" in
  5. msys*) python="winpty python";;
  6. *) python="python";;
  7. esac
  8. venv() {
  9. env_dir=./third_party/env/coremltools
  10. [ -d "${env_dir}" ] || ${python} -m venv ${env_dir}
  11. case "${env_dir}" in
  12. msys*) source ${env_dir}/Scripts/activate;;
  13. *) source ${env_dir}/bin/activate;;
  14. esac
  15. ${python} -m pip install --quiet --upgrade pip
  16. }
  17. clean() {
  18. echo "coreml clean"
  19. rm -rf "./third_party/source/env/coremltools"
  20. rm -rf "./third_party/source/coremltools"
  21. }
  22. sync() {
  23. echo "coreml sync"
  24. [ -d "./third_party/source/coremltools" ] || git clone --quiet https://github.com/apple/coremltools.git "./third_party/source/coremltools"
  25. git -C "./third_party/source/coremltools" pull --quiet --prune
  26. }
  27. schema() {
  28. echo "coreml schema"
  29. [[ $(grep -U $'\x0D' ./source/coreml-proto.js) ]] && crlf=1
  30. node ./tools/protoc.js --root coreml --out ./source/coreml-proto.js --path ./third_party/source/coremltools/mlmodel/format Model.proto
  31. if [[ -n ${crlf} ]]; then
  32. unix2dos --quiet --newfile ./source/coreml-proto.js ./source/coreml-proto.js
  33. fi
  34. }
  35. while [ "$#" != 0 ]; do
  36. command="$1" && shift
  37. case "${command}" in
  38. "clean") clean;;
  39. "sync") sync;;
  40. "schema") schema;;
  41. esac
  42. done