Skip to content

A template for kick starting a Rust, WebGPU and ONNX project using wgpu and wonnx.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Sager611/wgpu-wonnx-template

Repository files navigation

wgpu-wonnx-template

A template for kick starting a Rust, WebGPU and ONNX project using wgpu and wonnx.

Build Status

📝 About

ATTENTION: You need a WebGPU compatible browser to run your project on web.

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.

💡 Usage

Quickstart a project named my-project:

cargo generate --git https://github.com/Sager611/wgpu-wonnx-template.git --name my-project
cd my-project

🚀 Build & Run your 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:

  • wasm-pack: to compile to WebAssembly.
  • npm: to install and run the web application under www/.

Finally, wonnx uses compute shaders, which on web are only available by enabling WebGPU on your browser.

⚒️ Build for desktop

  • Debug:
just desktop
  • Release:
just desktop --release

⚒️ Build for web

  • Debug:
just web
  • Release:
just web --release

Resulting web project is saved under www/.

🏎️ Run on desktop

  • Debug:
just run-desktop
  • Release:
just run-desktop --release

🏎️ Run on web

  • Debug:
just run-web
  • Release:
just run-web --release

Then, open localhost:8080 in your browser.

💻 Enabling WebGPU on 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

Firefox

You need to install Firefox Nightly.

Then, follow these steps:

  • Go to about:config.
  • Set dom.webgpu.enabled and gfx.webgpu.force-enabled to true.

Chrome

You need to install Chrome Canary.

Then, follow these steps:

  • Go to chrome:https://flags.
  • Set Unsafe WebGPU and WebGPU Developer Features to Enabled.

⚖️ Licensing

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:

About

A template for kick starting a Rust, WebGPU and ONNX project using wgpu and wonnx.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published