keras 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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=python3;;
  7. esac
  8. bold() {
  9. echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
  10. }
  11. venv() {
  12. env_dir=./third_party/env/keras
  13. [ -d "${env_dir}" ] || ${python} -m venv ${env_dir}
  14. case "${OSTYPE}" in
  15. msys*) source ${env_dir}/Scripts/activate;;
  16. *) source ${env_dir}/bin/activate;;
  17. esac
  18. ${python} -m pip install --quiet --upgrade pip setuptools
  19. }
  20. clean() {
  21. bold "keras clean"
  22. rm -rf "./third_party/env/keras"
  23. rm -rf "./third_party/src/keras"
  24. }
  25. sync() {
  26. bold "keras sync"
  27. [ -d "./third_party/src/keras" ] || git clone --quiet https://github.com/keras-team/keras.git "./third_party/src/keras"
  28. pushd "./third_party/src/keras" > /dev/null
  29. git pull --quiet --prune
  30. popd > /dev/null
  31. }
  32. install() {
  33. bold "keras install"
  34. case "${OSTYPE}" in
  35. msys*) [ ! -z "$(choco list --local-only --exacty --limit-output vcredist140)" ] || $(choco install -yes vcredist140) > /dev/null;;
  36. esac
  37. venv
  38. ${python} -m pip install --quiet --upgrade tensorflow
  39. ${python} -m pip install --quiet ./third_party/src/keras
  40. deactivate
  41. }
  42. metadata() {
  43. bold "keras metadata"
  44. [[ $(grep -U $'\x0D' ./src/keras-metadata.json) ]] && crlf=1
  45. venv
  46. export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
  47. ${python} ./tools/keras-script.py metadata
  48. deactivate
  49. if [[ -n ${crlf} ]]; then
  50. unix2dos --quiet --newfile ./src/keras-metadata.json ./src/keras-metadata.json
  51. fi
  52. }
  53. zoo() {
  54. bold "keras zoo"
  55. venv
  56. export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
  57. ${python} ./tools/keras-script.py zoo
  58. deactivate
  59. }
  60. while [ "$#" != 0 ]; do
  61. command="$1" && shift
  62. case "${command}" in
  63. "clean") clean;;
  64. "sync") sync;;
  65. "install") install;;
  66. "metadata") metadata;;
  67. "zoo") zoo;;
  68. esac
  69. done