diff --git a/Dockerfile b/Dockerfile index 800bce6c9..254faa393 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM photoprism/development:20181107 +FROM photoprism/development:20181108 # Set up project directory WORKDIR "/go/src/github.com/photoprism/photoprism" diff --git a/Makefile b/Makefile index 38bafbc74..a398cd37b 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ GOIMPORTS=goimports BINARY_NAME=photoprism DOCKER_TAG=`date -u +%Y%m%d` -all: tensorflow-model dep js build +all: download dep js build install: install-bin install-assets install-config install-bin: cp $(BINARY_NAME) /usr/local/bin/$(BINARY_NAME) @@ -50,8 +50,8 @@ test-coverage: clean: $(GOCLEAN) rm -f $(BINARY_NAME) -tensorflow-model: - scripts/download-tf-model.sh +download: + scripts/download-inception.sh deploy-photoprism: scripts/docker-build.sh photoprism $(DOCKER_TAG) scripts/docker-push.sh photoprism $(DOCKER_TAG) diff --git a/docker/development/Dockerfile b/docker/development/Dockerfile index a0d0b3d76..4655279c8 100644 --- a/docker/development/Dockerfile +++ b/docker/development/Dockerfile @@ -70,6 +70,12 @@ ENV NODE_ENV production RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" +# Download TensorFlow model and test files +RUN rm -rf /tmp/* && mkdir -p /tmp/photoprism +RUN wget "https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip" -O /tmp/photoprism/inception.zip +RUN wget "https://www.dropbox.com/s/na9p9wwt98l7m5b/import.zip?dl=1" -O /tmp/photoprism/testdata.zip + +# Install goimports RUN env GO111MODULE=off /usr/local/go/bin/go get golang.org/x/tools/cmd/goimports # Expose HTTP port diff --git a/docker/photoprism/Dockerfile b/docker/photoprism/Dockerfile index b024909b8..835ad6f30 100644 --- a/docker/photoprism/Dockerfile +++ b/docker/photoprism/Dockerfile @@ -1,4 +1,4 @@ -FROM photoprism/development:20181107 as build +FROM photoprism/development:20181108 as build # Set up project directory WORKDIR "/go/src/github.com/photoprism/photoprism" diff --git a/docker/tensorflow/Dockerfile b/docker/tensorflow/Dockerfile index 017e18f43..3cad77e2c 100644 --- a/docker/tensorflow/Dockerfile +++ b/docker/tensorflow/Dockerfile @@ -1,4 +1,4 @@ -FROM photoprism/development:20181107 +FROM photoprism/development:20181108 # Install Python and TensorFlow RUN apt-get update && apt-get install -y --no-install-recommends \ diff --git a/go.mod b/go.mod index a73852c6f..8ed0f4697 100644 --- a/go.mod +++ b/go.mod @@ -50,5 +50,5 @@ require ( gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/go-playground/validator.v8 v8.18.2 // indirect gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect - gopkg.in/yaml.v2 v2.2.1 + gopkg.in/yaml.v2 v2.2.1 // indirect ) diff --git a/internal/photoprism/config_test.go b/internal/photoprism/config_test.go index c79153d43..e3c276903 100644 --- a/internal/photoprism/config_test.go +++ b/internal/photoprism/config_test.go @@ -19,11 +19,11 @@ import ( const testDataPath = "testdata" const testDataURL = "https://www.dropbox.com/s/na9p9wwt98l7m5b/import.zip?dl=1" -const testDataHash = "ed3bdb2fe86ea662bc863b63e219b47b8d9a74024757007f7979887d" +const testDataHash = "1a59b358b80221ab3e76efb683ad72402f0b0844" const testConfigFile = "../../configs/photoprism.yml" var darktableCli = "/usr/bin/darktable-cli" -var testDataZip = GetExpandedFilename(testDataPath + "/import.zip") +var testDataZip = "/tmp/photoprism/testdata.zip" var assetsPath = GetExpandedFilename("../../assets") var thumbnailsPath = GetExpandedFilename(testDataPath + "/thumbnails") var originalsPath = GetExpandedFilename(testDataPath + "/originals") @@ -213,6 +213,8 @@ func unzip(src, dest string) ([]string, error) { } func downloadFile(filepath string, url string) (err error) { + os.MkdirAll("/tmp/photoprism", os.ModePerm) + // Create the file out, err := os.Create(filepath) if err != nil { diff --git a/internal/photoprism/tensorflow.go b/internal/photoprism/tensorflow.go index 7dda498ba..a7798c702 100644 --- a/internal/photoprism/tensorflow.go +++ b/internal/photoprism/tensorflow.go @@ -93,7 +93,7 @@ func (t *TensorFlow) loadModel() error { } // Load inception model - model, err := ioutil.ReadFile(t.modelPath + "/tensorflow_inception_graph.pb") + model, err := ioutil.ReadFile(t.modelPath + "/inception/tensorflow_inception_graph.pb") if err != nil { return err } @@ -103,7 +103,7 @@ func (t *TensorFlow) loadModel() error { } // Load labels - labelsFile, err := os.Open(t.modelPath + "/imagenet_comp_graph_label_strings.txt") + labelsFile, err := os.Open(t.modelPath + "/inception/imagenet_comp_graph_label_strings.txt") if err != nil { return err } diff --git a/scripts/download-inception.sh b/scripts/download-inception.sh new file mode 100755 index 000000000..6ac979eba --- /dev/null +++ b/scripts/download-inception.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +FILENAME="/tmp/photoprism/inception.zip" + +if [[ ! -e assets/tensorflow/inception/tensorflow_inception_graph.pb ]]; then + if [[ ! -e ${FILENAME} ]]; then + mkdir -p /tmp/photoprism + wget "https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip" -O ${FILENAME} + fi + + mkdir -p assets/tensorflow/inception + unzip ${FILENAME} -d assets/tensorflow/inception +else + echo "TensorFlow InceptionV3 model already downloaded." +fi \ No newline at end of file diff --git a/scripts/download-tf-model.sh b/scripts/download-tf-model.sh deleted file mode 100755 index 20b4dab55..000000000 --- a/scripts/download-tf-model.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -if [[ ! -e assets/tensorflow/tensorflow_inception_graph.pb ]]; then - wget "https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip" -O assets/tensorflow/inception.zip && - unzip assets/tensorflow/inception.zip -d assets/tensorflow -else - echo "TensorFlow InceptionV3 model already downloaded." -fi \ No newline at end of file