Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README for HTTPS and fetch weights files from CDN instead #196

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ node_modules/
**/*.ark
.DS_Store
package-lock.json
cert.pem
key.pem
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ To get started, follow these steps:
1. Clone the repository to your local machine and navigate to it:
```bash
> git clone --recurse-submodules https://github.com/webmachinelearning/webnn-samples
> cd webnn-samples & npm install
> cd webnn-samples
> openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
> npm install
> npm start
```
2. Navigate to the desired sample directory that you want to explore.
Expand Down
2 changes: 1 addition & 1 deletion face_recognition/facenet_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class FaceNetNchw {
this.context_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/facenet_nchw/weights';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/facenet_nchw/weights';
this.inputOptions = {
mean: [127.5, 127.5, 127.5, 127.5],
std: [127.5, 127.5, 127.5, 127.5],
Expand Down
2 changes: 1 addition & 1 deletion face_recognition/facenet_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class FaceNetNhwc {
this.context_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/facenet_nhwc/weights';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/facenet_nhwc/weights';
this.inputOptions = {
mean: [127.5, 127.5, 127.5, 127.5],
std: [127.5, 127.5, 127.5, 127.5],
Expand Down
2 changes: 1 addition & 1 deletion facial_landmark_detection/face_landmark_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class FaceLandmarkNchw {
this.context_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/face_landmark_nchw/weights';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/face_landmark_nchw/weights';
this.inputOptions = {
inputLayout: 'nchw',
inputDimensions: [1, 3, 128, 128],
Expand Down
2 changes: 1 addition & 1 deletion facial_landmark_detection/face_landmark_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class FaceLandmarkNhwc {
this.context_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/face_landmark_nhwc/weights';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/face_landmark_nhwc/weights';
this.inputOptions = {
inputLayout: 'nhwc',
inputDimensions: [1, 128, 128, 3],
Expand Down
2 changes: 1 addition & 1 deletion facial_landmark_detection/ssd_mobilenetv2_face_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class SsdMobilenetV2FaceNchw {
this.deviceType_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/ssd_mobilenetv2_face_nchw/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/ssd_mobilenetv2_face_nchw/weights/';
this.inputOptions = {
inputLayout: 'nchw',
margin: [1.2, 1.2, 0.8, 1.1],
Expand Down
2 changes: 1 addition & 1 deletion facial_landmark_detection/ssd_mobilenetv2_face_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class SsdMobilenetV2FaceNhwc {
this.deviceType_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/ssd_mobilenetv2_face_nhwc/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/ssd_mobilenetv2_face_nhwc/weights/';
this.inputOptions = {
inputLayout: 'nhwc',
margin: [1.2, 1.2, 0.8, 1.1],
Expand Down
2 changes: 1 addition & 1 deletion image_classification/mobilenet_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class MobileNetV2Nchw {
this.deviceType_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/mobilenetv2_nchw/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/mobilenetv2_nchw/weights/';
this.inputOptions = {
mean: [0.485, 0.456, 0.406],
std: [0.229, 0.224, 0.225],
Expand Down
2 changes: 1 addition & 1 deletion image_classification/mobilenet_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class MobileNetV2Nhwc {
this.deviceType_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/mobilenetv2_nhwc/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/mobilenetv2_nhwc/weights/';
this.inputOptions = {
mean: [127.5, 127.5, 127.5],
std: [127.5, 127.5, 127.5],
Expand Down
2 changes: 1 addition & 1 deletion image_classification/resnet50v2_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class ResNet50V2Nchw {
this.context_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/resnet50v2_nchw/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/resnet50v2_nchw/weights/';
this.inputOptions = {
mean: [0.485, 0.456, 0.406],
std: [0.229, 0.224, 0.225],
Expand Down
2 changes: 1 addition & 1 deletion image_classification/resnet50v2_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ResNet50V2Nhwc {
this.context_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/resnet50v2_nhwc/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/resnet50v2_nhwc/weights/';
this.inputOptions = {
mean: [127.5, 127.5, 127.5],
std: [127.5, 127.5, 127.5],
Expand Down
2 changes: 1 addition & 1 deletion image_classification/squeezenet_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class SqueezeNetNchw {
this.context_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/squeezenet1.1_nchw/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/squeezenet1.1_nchw/weights/';
this.inputOptions = {
mean: [0.485, 0.456, 0.406],
std: [0.229, 0.224, 0.225],
Expand Down
2 changes: 1 addition & 1 deletion image_classification/squeezenet_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class SqueezeNetNhwc {
this.context_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/squeezenet1.0_nhwc/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/squeezenet1.0_nhwc/weights/';
this.inputOptions = {
mean: [127.5, 127.5, 127.5],
std: [127.5, 127.5, 127.5],
Expand Down
2 changes: 1 addition & 1 deletion lenet/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function main() {
await utils.setBackend(backend, deviceType);
drawNextDigitFromMnist();
const pen = new Pen(visualCanvas);
const weightUrl = '../test-data/models/lenet_nchw/weights/lenet.bin';
const weightUrl = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/lenet_nchw/weights/lenet.bin';
const lenet = new LeNet(weightUrl);
const [numRuns, powerPreference, numThreads] = utils.getUrlParams();
try {
Expand Down
2 changes: 1 addition & 1 deletion nsnet2/denoiser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Denoiser {
return new Promise((resolve, reject) => {
this.log(' - Loading weights... ');
const start = performance.now();
const weightsUrl = '../test-data/models/nsnet2/weights/';
const weightsUrl = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/nsnet2/weights/';
const powerPreference = getUrlParams()[1];
const contextOptions = {deviceType};
if (powerPreference) {
Expand Down
4 changes: 2 additions & 2 deletions object_detection/ssd_mobilenetv1_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export class SsdMobilenetV1Nchw {
this.model_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/ssd_mobilenetv1_nchw/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/ssd_mobilenetv1_nchw/weights/';
// Shares the same bias files with 'nhwc' layout
this.biasUrl_ = '../test-data/models/ssd_mobilenetv1_nhwc/weights/';
this.biasUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/ssd_mobilenetv1_nhwc/weights/';
this.inputOptions = {
inputLayout: 'nchw',
labelUrl: './labels/coco_classes.txt',
Expand Down
2 changes: 1 addition & 1 deletion object_detection/ssd_mobilenetv1_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class SsdMobilenetV1Nhwc {
this.model_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/ssd_mobilenetv1_nhwc/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/ssd_mobilenetv1_nhwc/weights/';
this.inputOptions = {
inputLayout: 'nhwc',
labelUrl: './labels/coco_classes.txt',
Expand Down
2 changes: 1 addition & 1 deletion object_detection/tiny_yolov2_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class TinyYoloV2Nchw {
this.context_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/tiny_yolov2_nchw/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/tiny_yolov2_nchw/weights/';
this.inputOptions = {
inputLayout: 'nchw',
labelUrl: './labels/pascal_classes.txt',
Expand Down
2 changes: 1 addition & 1 deletion object_detection/tiny_yolov2_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class TinyYoloV2Nhwc {
this.context_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/tiny_yolov2_nhwc/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/tiny_yolov2_nhwc/weights/';
this.inputOptions = {
inputLayout: 'nhwc',
labelUrl: './labels/pascal_classes.txt',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"scripts": {
"lint": "eslint . --ext .js",
"start": "http-server"
"start": "http-server -S cert.pem -o"
},
"dependencies": {
"babel-eslint": "^8.0.3"
Expand Down
2 changes: 1 addition & 1 deletion rnnoise/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const batchSize = 1;
const frames = 100; // Frames is fixed at 100
const frameSize = 480;
const gainsSize = 22;
const weightsUrl = '../test-data/models/rnnoise/weights/';
const weightsUrl = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/rnnoise/weights/';
const rnnoise = new RNNoise(weightsUrl, batchSize, frames);

$('#backendBtns .btn').on('change', async () => {
Expand Down
4 changes: 2 additions & 2 deletions semantic_segmentation/deeplabv3_mnv2_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class DeepLabV3MNV2Nchw {
this.deviceType_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/deeplabv3_mnv2_nchw/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/deeplabv3_mnv2_nchw/weights/';
// Shares the same bias files with 'nhwc' layout
this.biasUrl_ = '../test-data/models/deeplabv3_mnv2_nhwc/weights/';
this.biasUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/deeplabv3_mnv2_nhwc/weights/';
this.inputOptions = {
mean: [127.5, 127.5, 127.5],
std: [127.5, 127.5, 127.5],
Expand Down
2 changes: 1 addition & 1 deletion semantic_segmentation/deeplabv3_mnv2_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class DeepLabV3MNV2Nhwc {
this.deviceType_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = '../test-data/models/deeplabv3_mnv2_nhwc/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/deeplabv3_mnv2_nhwc/weights/';
this.inputOptions = {
mean: [127.5, 127.5, 127.5],
std: [127.5, 127.5, 127.5],
Expand Down
2 changes: 1 addition & 1 deletion style_transfer/fast_style_transfer_net.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class FastStyleTransferNet {
this.graph_ = null;
this.constPow_ = null;
this.constAdd_ = null;
this.weightsUrl_ = '../test-data/models/fast_style_transfer_nchw/weights/';
this.weightsUrl_ = 'https://d3i5xkfad89fac.cloudfront.net/test-data/models/fast_style_transfer_nchw/weights/';
this.inputOptions = {
inputDimensions: [1, 3, 540, 540],
inputLayout: 'nchw',
Expand Down