keras 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. set -e
  3. root=$(cd $(dirname ${0})/..; pwd)
  4. build=${root}/build
  5. test=${root}/test
  6. third_party=${root}/third_party
  7. tools=${root}/tools
  8. identifier=keras
  9. virtualenv=${third_party}/virtualenv/${identifier}
  10. bold() {
  11. echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
  12. }
  13. git_sync() {
  14. mkdir -p "${third_party}"
  15. if [ -d "${third_party}/${1}" ]; then
  16. git -C "${third_party}/${1}" pull --quiet --prune
  17. else
  18. git -C "${third_party}" clone --quiet --recursive ${2}
  19. fi
  20. git -C "${third_party}/${1}" submodule sync --quiet
  21. git -C "${third_party}/${1}" submodule update --quiet --init --recursive
  22. }
  23. clean() {
  24. bold "keras clean"
  25. rm -rf ${virtualenv}
  26. rm -rf ${third_party}/${identifier}
  27. }
  28. sync() {
  29. bold "keras sync"
  30. git_sync keras https://github.com/keras-team/keras.git
  31. }
  32. install() {
  33. bold "keras install"
  34. [ -n "$(python3 -m pip list --format columns --disable-pip-version-check | grep -w virtualenv)" ] || python3 -m pip install --force-reinstall --user --quiet virtualenv
  35. [ -d "${virtualenv}" ] || virtualenv --quiet -p python3 ${virtualenv}
  36. source ${virtualenv}/bin/activate
  37. python3 -m pip install --quiet --upgrade tensorflow
  38. python3 -m pip install --quiet ${third_party}/${identifier}
  39. deactivate
  40. }
  41. metadata() {
  42. bold "keras metadata"
  43. source ${virtualenv}/bin/activate
  44. pushd ${tools} > /dev/null
  45. python3 keras-script.py metadata
  46. popd > /dev/null
  47. deactivate
  48. }
  49. zoo() {
  50. bold "keras zoo"
  51. source ${virtualenv}/bin/activate
  52. pushd ${tools} > /dev/null
  53. python3 keras-script.py zoo
  54. popd > /dev/null
  55. deactivate
  56. }
  57. while [ "$#" != 0 ]; do
  58. command="$1" && shift
  59. case "${command}" in
  60. "clean") clean;;
  61. "sync") sync;;
  62. "install") install;;
  63. "metadata") metadata;;
  64. "zoo") zoo;;
  65. esac
  66. done