Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*.cpuprofile
dist/
node_modules/
local_models/
www/node_modules/
www/data/src/WebGazerETRA2018Dataset_Release20180420/
www/data/src/P*/
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"clean": "rimraf dist",
"prebuild": "npm run clean",
"dev": "webpack --progress --config webpack.config.js --mode development",
"localbuild": "npm run build && ./scripts/localize_build.sh",
"build": "webpack --progress --config webpack.config.js --mode production",
"gen_docs": "jsdoc -c jsdoc.conf.json src/*"
},
Expand Down
13 changes: 13 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Localized build

This script downloads the TFJS models from Kaggle and replaces the URLs in the installed npm packages with local
paths. Please note that it is currently a hacky workaround. You will need to make sure the local_models folder also exists wherever the built webgazer.js exists.


To compile WebGazer for local use, first read and verify `localize_build.sh`, then

`chmod +x ./scripts/localize_build.sh`

then run

`npm run localbuild`
43 changes: 43 additions & 0 deletions scripts/localize_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# downloads models into local_models if they don't already exist
# then replaces tensorflow online calls with local paths in the dist


FACEMESH_URL="https://tfhub.dev/mediapipe/tfjs-model/facemesh/1/default/1"
IRIS_URL="https://tfhub.dev/mediapipe/tfjs-model/iris/1/default/2"
BLAZEFACE_URL="https://tfhub.dev/tensorflow/tfjs-model/blazeface/1/default/1"

FACEMESH_LOCAL_PATH="./local_models/facemesh/"
IRIS_LOCAL_PATH="./local_models/iris/"
BLAZEFACE_LOCAL_PATH="./local_models/blazeface/"

if [ ! -d "./local_models" ]; then
mkdir -p ./local_models
mkdir -p ./local_models/facemesh
mkdir -p ./local_models/iris
mkdir -p ./local_models/blazeface

curl -L -o ./local_models/facemesh.tar.gz \
https://www.kaggle.com/api/v1/models/mediapipe/facemesh/tfJs/default/1/download
tar -xzf ./local_models/facemesh.tar.gz -C $FACEMESH_LOCAL_PATH
rm ./local_models/facemesh.tar.gz


curl -L -o ./local_models/iris.tar.gz \
https://www.kaggle.com/api/v1/models/mediapipe/iris/tfJs/default/2/download
tar -xzf ./local_models/iris.tar.gz -C $IRIS_LOCAL_PATH
rm ./local_models/iris.tar.gz

curl -L -o ./local_models/blazeface.tar.gz \
https://www.kaggle.com/api/v1/models/tensorflow/blazeface/tfJs/default/1/download
tar -xzf ./local_models/blazeface.tar.gz -C $BLAZEFACE_LOCAL_PATH
rm ./local_models/blazeface.tar.gz
fi

find ./dist/ -type f -exec sed -i \
-e "s#$FACEMESH_URL#$FACEMESH_LOCAL_PATH#g" \
-e "s#$IRIS_URL#$IRIS_LOCAL_PATH#g" \
-e "s#$BLAZEFACE_URL#$BLAZEFACE_LOCAL_PATH#g" {} +

echo "localization finished"