webmachinelearning / webnn-samples Goto Github PK
View Code? Open in Web Editor NEW🧠✨ Web Neural Network API samples
Home Page: https://webmachinelearning.github.io/webnn-samples/
License: Apache License 2.0
🧠✨ Web Neural Network API samples
Home Page: https://webmachinelearning.github.io/webnn-samples/
License: Apache License 2.0
Use the fused activation of conv2d and batchNormalization that was introduced by webmachinelearning/webnn#188
Related webnn-polyfill PR: webmachinelearning/webnn-polyfill#98
Repro Steps:
Actual Result:
When the number in the picture are cleared, it can still be predicted.
Environment:
Chrome Canary: 125.0.6381.0
Device | OS | CPU | GPU |
---|---|---|---|
Laptop | Windows 11 23H2 | Ultra 7 155H | Intel Arc Graphics |
- [ ] Image classification (ResNet50v2 NHWC model)
Refer to latest Spec change webmachinelearning/webnn#355
Align with webmachinelearning/webnn#206:
ClampOptions {
float minValue;
float maxValue;
};
This sample would be according to WebNN semantic segmentation use case.
Now that the Chromium prototype supports passing "npu"
in the context creation options we need samples that exercise this code path.
I design to support https://webmachinelearning.github.io/webnn-samples/lenet/?numRuns={n} and update UI by adding 'numRuns' input, show median Execution Time on UI when 'numRuns' is greater than 1.
@huningxin Any suggestion, thanks.
The TinyYOLO is one of the first wave models.
Refer to WebNN Super Resolution use case: https://webmachinelearning.github.io/webnn/#usecase-super-resolution
Maybe this one in the ONNX Runtime project could be a start point model.
The WebNN reshape spec is updated to use null to indicate the dimension that needs to be calculated: https://www.w3.org/TR/webnn/#api-mlgraphbuilder-reshape
We need to fix samples which use reshape with old -1.
https://github.com/webmachinelearning/webnn-samples/actions/runs/873331801
@Honry , please help fix this issue. Thanks!
Repro Steps:
Launch latest Chrome Canary on Windows 11
C:\Users\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --enable-features=WebMachineLearningNeuralNetwork
Visit https://webmachinelearning.github.io/webnn-samples/style_transfer/index.html
Choose webnn-cpu backend
Actual Result:
DOMException: Failed to execute 'build' on 'MLGraphBuilder': XNNPACK only supports constant padding mode.
Environment:
Chrome Canary: 125.0.6381.0
Device | OS | CPU | GPU |
---|---|---|---|
Laptop | Windows 11 23H2 | Ultra 7 155H | Intel Arc Graphics |
The RNNoise is one of the first wave models.
Enable the CI for lint as the first step.
Host the LeNet example at https://webmachinelearning.github.io/webnn-samples/lenet/
Steps to reproduce:
Load https://webmachinelearning.github.io/webnn-samples/code/?example=mul_add.js
Click Run
Console log prints:
Could not get context for WebGL version 2
Output shape: 2,2
Output value: 1,1,1,1
Output shape: 2,2
Output value: 1,1,1,1
Expected log messages in 3 and 5 to be identical, including the WebGL error message.
Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1
Repro Steps:
Launch latest Chrome Canary on Windows 11
C:\Users\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --enable-features=WebMachineLearningNeuralNetwork
Visit https://webmachinelearning.github.io/webnn-samples/nsnet2/index.html
or https://webmachinelearning.github.io/webnn-samples/rnnoise/index.html
Choose webnn-cpu backend
Actual Result:
DOMException: Failed to execute 'build' on 'MLGraphBuilder': XNNPACK can't support broadcasting for matrix multiply.
Environment:
Chrome Canary: 125.0.6381.0
Device | OS | CPU | GPU |
---|---|---|---|
Laptop | Windows 11 23H2 | Ultra 7 155H | Intel Arc Graphics |
The SqueezeNet is one of the first wave models.
The MobileNet is one of the first wave models.
Hi,
Can we add fp16 version of the models? (have all inputs and weights be fp16).
On Mac, CoreML only use NPU when the data is fp16. It would be valuable to have webnn samples with fp16 precision to compare the performance.
Repro Steps:
Actual Result:
e.target.close is not a function
Hi!
Thanks for making this available!
I get an error on the fast style transfer example saying:
"the value length 874800 is invalid, size of [1,3,33,33] 3267 is expected." and it never starts. This is on Chrome (also Canary) and Firefox, Mac OSX and POP_OS.
In the console it also shows: "Error with Permissions-Policy header: Unrecognized feature: 'interest-cohort'" but this may be unrelated.
Thanks,
Dirk
Add a live example based on the code example in WebNN spec
Repro Steps:
Launch latest Chrome Canary on Windows 11
C:\Users\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --enable-features=WebMachineLearningNeuralNetwork
Visit https://webmachinelearning.github.io/webnn-samples/nsnet2/index.html
or https://webmachinelearning.github.io/webnn-samples/rnnoise/index.html
Choose webnn-gpu backend
Actual Result:
DOMException: Failed to execute 'build' on 'MLGraphBuilder': DirectML: This operator (gru) is not supported.
Environment:
Chrome Canary: 125.0.6381.0
Device | OS | CPU | GPU |
---|---|---|---|
Laptop | Windows 11 23H2 | Ultra 7 155H | Intel Arc Graphics |
Currently the NNotepad code uses the Monaco editor with default (?) syntax highlighting, which is okay but not perfect.
Given that NNotepad has a well defined set of tokens and a grammar for parsing, and Monaco has a way to specify custom languages, we should be able to do better.
(Not urgent, this is just a "to-do" item.)
This is required by webmachinelearning/webnn#226
To implement this pipeline, the semantic segmentation sample probably could execute following steps:
VideoFrame
VideoFrame
into a WebGPU texture (GPUExternalTexture
)GPUExternalTexture
to a GPUBuffer
GPUBuffer
and the output is another GPUBuffer
GPUBuffer
and render the result to a canvas.VideoFrame
from the CanvasImageSource
and enqueue to the mediacapture-transform API's controller.Tried the sample here: https://webmachinelearning.github.io/webnn-samples/lenet/index.html and got the incorrect prediction for the handwritten number 7
Repro Steps:
Launch latest Chrome Canary on Windows 11 without WebNN flag
"C:\Users\AppData\Local\Google\Chrome SxS\Application\chrome.exe"
Visit https://webmachinelearning.github.io/webnn-samples/nsnet2/index.html
Choose wasm backend
Actual Result:
Error: Kernel 'Complex' not registered for backend 'wasm'.
Environment:
Chrome Canary: 125.0.6381.0
Device | OS | CPU | GPU |
---|---|---|---|
Laptop | Windows 11 23H2 | Ultra 7 155H | Intel Arc Graphics |
Normally, when serializing an expression into code, an array [...]
is serialized as a constant MLOperand. Since some methods take sequences, there's a WebNNUtil.isNonOperandArg()
helper that answers "for method X argument Y, should it be a constant MLOperand?". If this returns true, then a method arg is serialized as a JS array instead.
But this is not applied recursively. This is sufficient for this case:
T = [[1,2],[3,4]]
concat([T, T], 1)
... where concat() wants an array of tensors. But not for:
T = [[1,2],[3,4]]
reshape(data, [1, 2, 2, 1])
... where reshape wants an array of numbers (not scalar constants).
The ResNet is one of the first wave models.
In 2020/10/01 WebML CG call, @pyu10055 suggested
<ping_yu> It would be good to integrate this (code examples) with the spec doc
Implement the changes introduced by webmachinelearning/webnn#174
The changes include:
- Change
MLGraphBuilder.build
andMLGraph.compute
to sync API.- Change
MLGraph.compute
to require pre-allocated output buffers.- Simplify the the input / output resources binding by
MLResource
. LeaveMLInput
only for dynamic input shape case.
The webnn-polyfill PR webmachinelearning/webnn-polyfill#85 is ready to merge.
Please adapt to that change before we merge that PR which will break the samples. Thanks!
Hi, is it possible to get python implementation of NesNet2.
To align with latest spec: webmachinelearning/webnn#323
The NSNet is one of the first wave models.
Repro:
a = 123
, press backspace/deleteExpected:
Actual:
split()
example)Notes:
"input"
event listener to the #input
element, which calls refresh()
. The Monaco editor must not be firing this for deletion events? Is there a better way to listen to the Monaco editor?It would be good that users can run samples with different device by configuring the device preference.
https://webmachinelearning.github.io/webnn/#enumdef-mldevicepreference
For example, allow to select 'cpu', 'gpu' or 'default' for image classification sample and others.
The bias is 1D tensor that isn't supported in WebNN, please reshape it to 2D like native implementation
https://github.com/webmachinelearning/webnn-samples/blob/master/image_classification/mobilenet_nchw.js#L44
const bias = await buildConstantByNpy(this.builder_, biasName);
Both YOLO and SSD models are referred in WebNN object detection use case. Now the object detection sample supports TinyYOLOV2. It would be good to support SSD as well.
Hi,
I am looking for Face detection and recognition samples migrated to new repository, but i don't see any specific samples there, and i tried samples from old repository ([https://github.com/intel/webml-polyfill [github.com]) but those are crashing in the live camera case. we are looking for latest libraries which support FR/FD functionality to use in our project. so anything available immediately is of great help.
Regards
Roshan
webmachinelearning/webnn#149 introduces
The corresponding webnn-polyfill issue webmachinelearning/webnn-polyfill#42 and PR webmachinelearning/webnn-polyfill#46
Please follow https://github.com/webmachinelearning/webnn-polyfill/tree/master/.github
We need:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.