keras 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/bash
  2. set -e
  3. root=$(cd $(dirname ${0})/..; pwd)
  4. build=${root}/build
  5. test=${root}/test
  6. tools=${root}/tools
  7. third_party=${root}/third_party
  8. python="python"
  9. pip="pip"
  10. identifier=keras
  11. virtualenv=${build}/virtualenv/${identifier}
  12. bold() {
  13. echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
  14. }
  15. git_sync() {
  16. mkdir -p "${third_party}"
  17. if [ -d "${third_party}/${1}" ]; then
  18. git -C "${third_party}/${1}" fetch --quiet -p
  19. git -C "${third_party}/${1}" reset --quiet --hard origin/master
  20. else
  21. echo "Clone ${2}..."
  22. git -C "${third_party}" clone --quiet --recursive ${2}
  23. fi
  24. git -C "${third_party}" submodule update --quiet --init
  25. }
  26. clean() {
  27. bold "keras clean"
  28. rm -rf ${virtualenv}
  29. rm -rf ${third_party}/${identifier}
  30. }
  31. sync() {
  32. bold "keras sync"
  33. git_sync keras https://github.com/keras-team/keras.git
  34. }
  35. install() {
  36. bold "keras install"
  37. if [ ! -d "${virtualenv}" ]; then
  38. virtualenv --quiet -p ${python} ${virtualenv}
  39. fi
  40. source ${virtualenv}/bin/activate
  41. ${pip} install --quiet tensorflow
  42. ${pip} install --quiet ${third_party}/${identifier}
  43. deactivate
  44. }
  45. metadata() {
  46. bold "keras metadata"
  47. source ${virtualenv}/bin/activate
  48. pushd ${tools} > /dev/null
  49. ${python} keras-script.py metadata
  50. popd > /dev/null
  51. deactivate
  52. }
  53. zoo() {
  54. bold "keras zoo"
  55. source ${virtualenv}/bin/activate
  56. pushd ${tools} > /dev/null
  57. ${python} keras-script.py zoo keras.applications.densenet.DenseNet121 ${test}/data/keras/DenseNet121.h5
  58. ${python} keras-script.py zoo keras.applications.inception_resnet_v2.InceptionResNetV2 ${test}/data/keras/InceptionResNetV2.h5
  59. ${python} keras-script.py zoo keras.applications.inception_v3.InceptionV3 ${test}/data/keras/InceptionV3.h5
  60. ${python} keras-script.py zoo keras.applications.mobilenet_v2.MobileNetV2 ${test}/data/keras/MobileNetV2.h5
  61. ${python} keras-script.py zoo keras.applications.nasnet.NASNetMobile ${test}/data/keras/NASNetMobile.h5
  62. ${python} keras-script.py zoo keras.applications.resnet50.ResNet50 ${test}/data/keras/ResNet50.h5
  63. ${python} keras-script.py zoo keras.applications.vgg16.VGG16 ${test}/data/keras/VGG16.h5
  64. ${python} keras-script.py zoo keras.applications.vgg19.VGG19 ${test}/data/keras/VGG19.h5
  65. ${python} keras-script.py zoo keras.applications.xception.Xception ${test}/data/keras/Xception.h5
  66. rm -rf ~/.keras/models
  67. popd > /dev/null
  68. deactivate
  69. }
  70. while [ "$#" != 0 ]; do
  71. command="$1" && shift
  72. case "${command}" in
  73. "clean") clean;;
  74. "sync") sync;;
  75. "install") install;;
  76. "metadata") metadata;;
  77. "zoo") zoo;;
  78. esac
  79. done