Add tensorflow model and test file to development image #39
This commit is contained in:
parent
ac31141669
commit
133c7964ad
|
@ -1,4 +1,4 @@
|
|||
FROM photoprism/development:20181107
|
||||
FROM photoprism/development:20181108
|
||||
|
||||
# Set up project directory
|
||||
WORKDIR "/go/src/github.com/photoprism/photoprism"
|
||||
|
|
6
Makefile
6
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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 \
|
||||
|
|
2
go.mod
2
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
|
||||
)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
15
scripts/download-inception.sh
Executable file
15
scripts/download-inception.sh
Executable file
|
@ -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
|
|
@ -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
|
Loading…
Reference in a new issue