-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnsfw_model
40 lines (30 loc) · 976 Bytes
/
nsfw_model
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
set -e
TODAY=$(date -u +%Y%m%d)
MODEL_NAME="NSFW"
MODEL_URL="https://dl.photoprism.app/tensorflow/nsfw.zip?$TODAY"
MODEL_PATH="assets/nsfw" # Changed this line
MODEL_ZIP="nsfw.zip"
MODEL_HASH="2e03ad3c6aec27c270c650d0574ff2a6291d992b $MODEL_ZIP"
MODEL_VERSION="$MODEL_PATH/version.txt"
MODEL_BACKUP="storage/backup/nsfw-$TODAY"
echo "Installing $MODEL_NAME model for TensorFlow…"
# Create directories
mkdir -p /tmp/photoprism
# 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 --inet4-only -c "${MODEL_URL}" -O ${MODEL_ZIP}
TMP_HASH=$(sha1sum ${MODEL_ZIP})
echo "${TMP_HASH}"
fi
# Unzip model
unzip ${MODEL_ZIP} -d /app/assets
echo "$MODEL_NAME $TODAY $MODEL_HASH" > ${MODEL_VERSION}
echo "Latest $MODEL_NAME installed."