This template comes with:
☑️ Minimal Node.js web project that binds to the WebAssembly under www/
.
☑️ Example model, texture, light and camera shader based on the learn-wgpu tutorial.
🔲 Example classification of rendered image using SqueezeNet ONNX model.
☑️ Auto-resizing of web canvas using ResizeObserver.
Quickstart a project named my-project
:
cargo generate --git https://github.com/Sager611/wgpu-wonnx-template.git --name my-project
cd my-project
We use just
as a multi-platform build toolchain.
- Install
just
with:
cargo install just
Additional dependencies are needed to build the web application:
Finally, wonnx
uses compute shaders, which on web are only available by enabling WebGPU on your browser.
- Debug:
just desktop
- Release:
just desktop --release
- Debug:
just web
- Release:
just web --release
Resulting web project is saved under www/
.
- Debug:
just run-desktop
- Release:
just run-desktop --release
- Debug:
just run-web
- Release:
just run-web --release
Then, open localhost:8080 in your browser.
The WebGPU API implementation is still in development on modern browsers, so it has to be enabled manually.
For information on all officially supported browsers and how to activate WebGPU, check here.
To check if WebGPU is currently enabled in your browser, along with the adapter limits, follow this link.
Here are some specific examples on how to enable WebGPU on Firefox and Chrome
You need to install Firefox Nightly.
Then, follow these steps:
- Go to
about:config
. - Set
dom.webgpu.enabled
andgfx.webgpu.force-enabled
totrue
.
You need to install Chrome Canary.
Then, follow these steps:
- Go to
chrome:https://flags
. - Set
Unsafe WebGPU
andWebGPU Developer Features
toEnabled
.
This template comes with the two most common licenses for Rust crates:
This template is also licensed under either of Apache-2.0 OR MIT, except for:
res/models/squeezenet-labels.txt
: under Apache-2.0 only.