keras 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 -p --quiet
  19. git -C "${third_party}/${1}" reset --quiet --hard origin/master
  20. else
  21. echo "Clone ${2}..."
  22. git -C "${third_party}" clone --recursive ${2}
  23. fi
  24. git -C "${third_party}" submodule update --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. virtualenv --quiet -p ${python} ${virtualenv}
  38. source ${virtualenv}/bin/activate
  39. ${pip} install --quiet tensorflow
  40. ${pip} install --quiet ${third_party}/${identifier}
  41. deactivate
  42. }
  43. metadata() {
  44. bold "keras metadata"
  45. source ${virtualenv}/bin/activate
  46. pushd ${tools} > /dev/null
  47. ${python} keras-script.py metadata
  48. popd > /dev/null
  49. deactivate
  50. }
  51. zoo() {
  52. bold "keras zoo"
  53. source ${virtualenv}/bin/activate
  54. pushd ${tools} > /dev/null
  55. ${python} keras-script.py zoo keras.applications.densenet.DenseNet121 ${test}/data/keras/DenseNet121.h5
  56. ${python} keras-script.py zoo keras.applications.inception_resnet_v2.InceptionResNetV2 ${test}/data/keras/InceptionResNetV2.h5
  57. ${python} keras-script.py zoo keras.applications.inception_v3.InceptionV3 ${test}/data/keras/InceptionV3.h5
  58. ${python} keras-script.py zoo keras.applications.mobilenet_v2.MobileNetV2 ${test}/data/keras/MobileNetV2.h5
  59. ${python} keras-script.py zoo keras.applications.nasnet.NASNetMobile ${test}/data/keras/NASNetMobile.h5
  60. ${python} keras-script.py zoo keras.applications.resnet50.ResNet50 ${test}/data/keras/ResNet50.h5
  61. ${python} keras-script.py zoo keras.applications.vgg16.VGG16 ${test}/data/keras/VGG16.h5
  62. ${python} keras-script.py zoo keras.applications.vgg19.VGG19 ${test}/data/keras/VGG19.h5
  63. ${python} keras-script.py zoo keras.applications.xception.Xception ${test}/data/keras/Xception.h5
  64. rm -rf ~/.keras/models
  65. popd > /dev/null
  66. deactivate
  67. }
  68. while [ "$#" != 0 ]; do
  69. command="$1" && shift
  70. case "${command}" in
  71. "clean") clean;;
  72. "sync") sync;;
  73. "install") install;;
  74. "metadata") metadata;;
  75. "zoo") zoo;;
  76. esac
  77. done