This repo is a fork of the
tflite-support repo, with the
addition of the tflite_model_runner related code to show how it is built
using bazel and emsdk.
- Add emscripten toolchain to the
WORKSPACE
file. This will set up emsdk and provide a useful build rule
wasm_cc_binarythat can be used to build WASM module from a cc_binary (see below). - I also added a small patch for the com_google_glog library. Without it, the emscripten build will fail on Mac/Linux. The glog v0.5.0 release has a fix for this issue, but it requires some TFLite code refactoring. I will talk to the TFLite team about this. For now we will just use the patch.
- The cpp code is here.
- The demo code is
here. To run the demo:
- Run
yarn && yarn buildin the demo directory.yarn buildruns build.sh where you can see how thebazel buildcommand is used and how to extract the output files. - Run
yarn startto start the demo locally. It creates a model runner instance with the MobilenetV2 model and classfies an image. See the script.js file for details about how things are used from the JS side. - Since this build configuration is for SIMD+multi-threading, please make
sure Chrome has these two features
turned on
from
chrome://flags.
- Run