2015-09-25 02:31:46 +08:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2015-10-09 22:48:06 +08:00
|
|
|
# Download OpenFace models.
|
2015-09-25 02:31:46 +08:00
|
|
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
2015-10-18 01:15:39 +08:00
|
|
|
die() {
|
|
|
|
echo >&2 $*
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
checkCmd() {
|
|
|
|
command -v $1 >/dev/null 2>&1 \
|
|
|
|
|| die "'$1' command not found. Please install from your package manager."
|
|
|
|
}
|
|
|
|
|
|
|
|
checkCmd wget
|
|
|
|
checkCmd bunzip2
|
2015-09-25 02:31:46 +08:00
|
|
|
|
|
|
|
mkdir -p dlib
|
|
|
|
if [ ! -f dlib/shape_predictor_68_face_landmarks.dat ]; then
|
2015-10-18 01:15:39 +08:00
|
|
|
printf "\n\n====================================================\n"
|
|
|
|
printf "Downloading dlib's public domain face landmarks model.\n"
|
2015-10-18 01:26:48 +08:00
|
|
|
printf "Reference: https://github.com/davisking/dlib-models\n\n"
|
|
|
|
printf "This will incur about 60MB of network traffic for the compressed\n"
|
2016-05-21 00:21:47 +08:00
|
|
|
printf "models that will decompress to about 100MB on disk.\n"
|
2015-10-18 01:15:39 +08:00
|
|
|
printf "====================================================\n\n"
|
2017-02-08 00:56:49 +08:00
|
|
|
wget -nv \
|
2017-02-08 00:33:01 +08:00
|
|
|
http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2 \
|
|
|
|
-O dlib/shape_predictor_68_face_landmarks.dat.bz2
|
2015-10-18 01:15:39 +08:00
|
|
|
[ $? -eq 0 ] || die "+ Error in wget."
|
2015-09-25 02:31:46 +08:00
|
|
|
bunzip2 dlib/shape_predictor_68_face_landmarks.dat.bz2
|
2015-10-18 01:15:39 +08:00
|
|
|
[ $? -eq 0 ] || die "+ Error using bunzip2."
|
2015-09-25 02:31:46 +08:00
|
|
|
fi
|
|
|
|
|
2015-10-09 22:48:06 +08:00
|
|
|
mkdir -p openface
|
2016-01-13 04:46:49 +08:00
|
|
|
if [ ! -f openface/nn4.small2.v1.t7 ]; then
|
2015-10-18 01:15:39 +08:00
|
|
|
printf "\n\n====================================================\n"
|
2016-01-13 04:46:49 +08:00
|
|
|
printf "Downloading OpenFace models, which are copyright\n"
|
|
|
|
printf "Carnegie Mellon University and are licensed under\n"
|
2015-10-18 01:26:48 +08:00
|
|
|
printf "the Apache 2.0 License.\n\n"
|
2016-01-12 05:23:05 +08:00
|
|
|
printf "This will incur about 100MB of network traffic for the models.\n"
|
2015-10-18 01:15:39 +08:00
|
|
|
printf "====================================================\n\n"
|
|
|
|
|
2017-02-08 00:56:49 +08:00
|
|
|
wget -nv \
|
2017-02-08 02:43:42 +08:00
|
|
|
https://storage.cmusatyalab.org/openface-models/nn4.small2.v1.t7 \
|
2017-02-08 00:33:01 +08:00
|
|
|
-O openface/nn4.small2.v1.t7
|
2016-01-13 04:46:49 +08:00
|
|
|
[ $? -eq 0 ] || ( rm openface/nn4.small2.v1.t7* && die "+ nn4.small2.v1.t7: Error in wget." )
|
2015-10-18 01:15:39 +08:00
|
|
|
|
2017-02-08 00:56:49 +08:00
|
|
|
wget -nv \
|
2017-02-08 02:43:42 +08:00
|
|
|
https://storage.cmusatyalab.org/openface-models/celeb-classifier.nn4.small2.v1.pkl \
|
2017-02-08 00:33:01 +08:00
|
|
|
-O openface/celeb-classifier.nn4.small2.v1.pkl
|
2016-01-13 04:46:49 +08:00
|
|
|
[ $? -eq 0 ] || ( rm openface/celeb-classifier.nn4.small2.v1.pkl && \
|
|
|
|
die "+ celeb-classifier.nn4.small2.v1.pkl: Error in wget." )
|
2015-09-25 02:31:46 +08:00
|
|
|
fi
|
2015-10-18 01:15:39 +08:00
|
|
|
|
|
|
|
printf "\n\n====================================================\n"
|
|
|
|
printf "Verifying checksums.\n"
|
|
|
|
printf "====================================================\n\n"
|
|
|
|
|
|
|
|
md5str() {
|
|
|
|
local FNAME=$1
|
|
|
|
case $(uname) in
|
|
|
|
"Linux")
|
|
|
|
echo $(md5sum "$FNAME" | cut -d ' ' -f 1)
|
|
|
|
;;
|
|
|
|
"Darwin")
|
|
|
|
echo $(md5 -q "$FNAME")
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
checkmd5() {
|
|
|
|
local FNAME=$1
|
|
|
|
local EXPECTED=$2
|
|
|
|
local ACTUAL=$(md5str "$FNAME")
|
2016-02-07 05:32:38 +08:00
|
|
|
if [ $EXPECTED = $ACTUAL ]; then
|
2015-10-18 01:15:39 +08:00
|
|
|
printf "+ $FNAME: successfully checked\n"
|
|
|
|
else
|
|
|
|
printf "+ ERROR! $FNAME md5sum did not match.\n"
|
|
|
|
printf " + Expected: $EXPECTED\n"
|
|
|
|
printf " + Actual: $ACTUAL\n"
|
|
|
|
printf " + Please manually delete this file and try re-running this script.\n"
|
2016-01-08 08:07:56 +08:00
|
|
|
return -1
|
2015-10-18 01:15:39 +08:00
|
|
|
fi
|
|
|
|
printf "\n"
|
|
|
|
}
|
|
|
|
|
2016-01-08 08:07:56 +08:00
|
|
|
set -e
|
|
|
|
|
2015-10-18 01:15:39 +08:00
|
|
|
checkmd5 \
|
|
|
|
dlib/shape_predictor_68_face_landmarks.dat \
|
|
|
|
73fde5e05226548677a050913eed4e04
|
|
|
|
|
|
|
|
checkmd5 \
|
2016-01-13 04:46:49 +08:00
|
|
|
openface/celeb-classifier.nn4.small2.v1.pkl \
|
|
|
|
199a2c0d32fd0f22f14ad2d248280475
|
2015-10-18 01:15:39 +08:00
|
|
|
|
|
|
|
checkmd5 \
|
2016-01-13 04:46:49 +08:00
|
|
|
openface/nn4.small2.v1.t7 \
|
|
|
|
c95bfd8cc1adf05210e979ff623013b6
|