Move TF model to download server to reduce git repo size, especially in case the model needs updates.
This commit is contained in:
parent
8c2b55efa4
commit
ccbf8d732e
4 changed files with 50 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
/frontend/node_modules/*
|
||||
/node_modules
|
||||
/assets/static/build/*
|
||||
/assets/facenet
|
||||
/assets/nasnet
|
||||
/assets/nsfw
|
||||
/storage
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,6 +9,7 @@
|
|||
/frontend/tests/*.html
|
||||
/frontend/tests/*.log
|
||||
/frontend/tests/screenshots
|
||||
/assets/facenet
|
||||
/assets/nasnet
|
||||
/assets/nsfw
|
||||
/assets/static/build/
|
||||
|
|
3
Makefile
3
Makefile
|
@ -70,7 +70,7 @@ install-assets:
|
|||
mkdir -p ~/.photoprism/assets
|
||||
mkdir -p ~/Pictures/Originals
|
||||
mkdir -p ~/Pictures/Import
|
||||
cp -r assets/locales assets/nasnet assets/nsfw assets/profiles assets/static assets/templates ~/.photoprism/assets
|
||||
cp -r assets/locales assets/facenet assets/nasnet assets/nsfw assets/profiles assets/static assets/templates ~/.photoprism/assets
|
||||
find ~/.photoprism/assets -name '.*' -type f -delete
|
||||
clean-local-assets:
|
||||
rm -rf ~/.photoprism/assets/*
|
||||
|
@ -89,6 +89,7 @@ dep-upgrade:
|
|||
dep-upgrade-js:
|
||||
(cd frontend && npm --depth 3 update --legacy-peer-deps)
|
||||
dep-tensorflow:
|
||||
scripts/download-facenet.sh
|
||||
scripts/download-nasnet.sh
|
||||
scripts/download-nsfw.sh
|
||||
zip-nasnet:
|
||||
|
|
46
scripts/download-facenet.sh
Executable file
46
scripts/download-facenet.sh
Executable file
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
TODAY=`date -u +%Y%m%d`
|
||||
|
||||
MODEL_NAME="Facenet"
|
||||
MODEL_URL="https://dl.photoprism.org/tensorflow/facenet.zip?$TODAY"
|
||||
MODEL_PATH="assets/facenet"
|
||||
MODEL_ZIP="/tmp/photoprism/facenet.zip"
|
||||
MODEL_HASH="0492eb1d67789108b7eefb274e26633504b059be $MODEL_ZIP"
|
||||
MODEL_VERSION="$MODEL_PATH/version.txt"
|
||||
MODEL_BACKUP="storage/backup/facenet-$TODAY"
|
||||
|
||||
echo "Installing $MODEL_NAME model for TensorFlow..."
|
||||
|
||||
# Create directories
|
||||
mkdir -p /tmp/photoprism
|
||||
mkdir -p storage/backup
|
||||
|
||||
# Check for update
|
||||
if [[ -f ${MODEL_ZIP} ]] && [[ `sha1sum ${MODEL_ZIP}` == ${MODEL_HASH} ]]; then
|
||||
if [[ -f ${MODEL_VERSION} ]]; then
|
||||
echo "Already up to date."
|
||||
exit
|
||||
fi
|
||||
else
|
||||
# Download model
|
||||
echo "Downloading latest model from $MODEL_URL..."
|
||||
wget ${MODEL_URL} -O ${MODEL_ZIP}
|
||||
|
||||
TMP_HASH=`sha1sum ${MODEL_ZIP}`
|
||||
|
||||
echo ${TMP_HASH}
|
||||
fi
|
||||
|
||||
# Create backup
|
||||
if [[ -e ${MODEL_PATH} ]]; then
|
||||
echo "Creating backup of existing directory: $MODEL_BACKUP"
|
||||
rm -rf ${MODEL_BACKUP}
|
||||
mv ${MODEL_PATH} ${MODEL_BACKUP}
|
||||
fi
|
||||
|
||||
# Unzip model
|
||||
unzip ${MODEL_ZIP} -d assets
|
||||
echo "$MODEL_NAME $TODAY $MODEL_HASH" > ${MODEL_VERSION}
|
||||
|
||||
echo "Latest $MODEL_NAME installed."
|
Loading…
Reference in a new issue