WebNN code samples
Simple WebNN examples to get started with understanding WebNN and try on Browser.
file | details |
---|---|
webnn_enable.html | Checks if WebNN is enabled or not in browser |
webnn_devices.html | Checks which of the WebNN devices (npu, gpu, cpu) are available |
webnn_device_select.html | Shows how to select a device to use WebNN |
webnn_compute.html | Selects a device and uses WebNN to do simple computation |
webnn_compute_large.html | Uses WebNN to do large computation and check device usage |
Simple WebNN samples showcasing AI inference using WebNN that can be run on Browser
Sample Name | Details |
---|---|
image_classification_onnx | The sample uses WebNN with ONNX Runtime Web library to build an image classification system on the web that uses ONNX model exported from HuggingFace. |
image_classification_transformers.js | The sample uses transformers.js library to build an image classification system on the web that uses model directly from HuggingFace or local model |
image_classification_webnn | The sample uses WebNN API directly to build an image classification system on the web that uses MobileNetV2 model. |
As of 01/2025, these examples work on Windows* 11 on Google* Chrome or Microsoft* Edge browser.