2021-07-16 12:16:56 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-05-21 02:34:50 +02:00
|
|
|
TODAY=$(date -u +%Y%m%d)
|
2021-07-16 12:16:56 +02:00
|
|
|
|
|
|
|
MODEL_NAME="Facenet"
|
2021-12-12 20:15:52 +01:00
|
|
|
MODEL_URL="https://dl.photoprism.app/tensorflow/facenet.zip?$TODAY"
|
2021-07-16 12:16:56 +02:00
|
|
|
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
|
2022-05-21 02:34:50 +02:00
|
|
|
mkdir -p /tmp/photoprism
|
|
|
|
mkdir -p storage/backup
|
2021-07-16 12:16:56 +02:00
|
|
|
|
|
|
|
# Check for update
|
2022-05-21 02:34:50 +02:00
|
|
|
if [[ -f ${MODEL_ZIP} ]] && [[ $(sha1sum ${MODEL_ZIP}) == ${MODEL_HASH} ]]; then
|
2021-07-16 12:16:56 +02:00
|
|
|
if [[ -f ${MODEL_VERSION} ]]; then
|
|
|
|
echo "Already up to date."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Download model
|
|
|
|
echo "Downloading latest model from $MODEL_URL..."
|
2022-08-10 09:02:46 +02:00
|
|
|
wget --inet4-only -c "${MODEL_URL}" -O ${MODEL_ZIP}
|
2021-07-16 12:16:56 +02:00
|
|
|
|
2022-05-21 02:34:50 +02:00
|
|
|
TMP_HASH=$(sha1sum ${MODEL_ZIP})
|
2021-07-16 12:16:56 +02:00
|
|
|
|
2022-03-16 19:09:53 +01:00
|
|
|
echo "${TMP_HASH}"
|
2021-07-16 12:16:56 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Create backup
|
|
|
|
if [[ -e ${MODEL_PATH} ]]; then
|
|
|
|
echo "Creating backup of existing directory: $MODEL_BACKUP"
|
2022-05-21 02:34:50 +02:00
|
|
|
rm -rf "${MODEL_BACKUP}"
|
|
|
|
mv ${MODEL_PATH} "${MODEL_BACKUP}"
|
2021-07-16 12:16:56 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Unzip model
|
2022-05-21 02:34:50 +02:00
|
|
|
unzip ${MODEL_ZIP} -d assets
|
2021-07-16 12:16:56 +02:00
|
|
|
echo "$MODEL_NAME $TODAY $MODEL_HASH" > ${MODEL_VERSION}
|
|
|
|
|
|
|
|
echo "Latest $MODEL_NAME installed."
|