commit | 5120e2a7ad3a3a7fb7746bef66b8c3d3614825b9 | [log] [tgz] |
---|---|---|
author | Dmitry Kovalev <dkovalev@google.com> | Wed May 05 23:40:54 2021 -0700 |
committer | Dmitry Kovalev <dkovalev@google.com> | Wed May 05 23:40:54 2021 -0700 |
tree | 3107f06d96f35b5ad0337e92f53bc29c7ecdde80 | |
parent | 6e943bf7878c90ef254bb3918e00ff43a0a8c009 [diff] |
Better logging Change-Id: I4d04436c9c73f80df833a8f338df8e43ea6250ae
This is a project to demonstrate how to use the Coral USB Accelerator from the Chrome browser with WebUSB.
Currently, this demo is verified to work only on Linux and macOS.
Clone this repo with submodules:
git clone --recurse-submodules https://github.com/google-coral/webcoral
Switch directory:
cd webcoral
Download .tflite
model files to site/models/
:
make download
Build WASM files inside a Docker container:
DOCKER_SHELL_COMMAND="make COMPILATION_MODE=opt wasm" make docker-shell
Run local web server using python:
make server
Server is listening on port 8000
.
On macOS, you don't need to install anything else.
On Linux, you need to install device rules to make the Coral USB Accelerator visible in Chrome. You probably already have them installed if you are using Coral products. If not, this repo has a bash script to install the device rules:
scripts/linux_device_rules.sh install
and corresponding uninstall command if needed:
scripts/linux_device_rules.sh uninstall
To use the USB Accelerator from the web browser, you need to update the USB Accelerator's firmware as follows. The firmware is usually automatically flashed by libedgetpu library when using C++ or Python programs, but that’s not the case from the browser.
If you run lsusb
command right after plugging USB device in, you'll see:
Bus 001 Device 008: ID 1a6e:089a Global Unichip Corp.
This means firmware is not flashed yet. It is possible to flash firmware directly from Chrome or using command line.
To flash firmware from command line:
make reset
To flash from Chrome browser, point it to http://localhost:8000/ and press Flash Device Firmware
button. WARNING: this only works on Linux now. There is an issue on macOS. It is already fixed and the fix will be available in Chrome 91.
Either way, you should now verify it's flashed by again running lsusb
and you should see:
Bus 001 Device 009: ID 18d1:9302 Google Inc.
which means that device is ready to use.
Open Chrome at http://localhost:8000/. Choose the model you want to run and press the Initialize Interpreter button. Selecting an Edge TPU model then requires you to select the USB Accelerator in the dialog; selecting a CPU model will be ready immediately. At this moment, you can run inference on any local image file by pressing the Choose Image File button.