Skip to content

Commit

Permalink
Make test-data as submodule to improve the load time of weight files
Browse files Browse the repository at this point in the history
  • Loading branch information
Honry committed Jul 12, 2021
1 parent baa61ec commit 6a19176
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 30 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ updates:
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"
labels:
- "ci"
- package-ecosystem: "gitsubmodule"
directory: "/"
schedule:
# Check for updates to git submodule every weekday
interval: "daily"
labels:
- "ci"
- "submodules"
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ jobs:
job:
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout repository and submodules
uses: actions/[email protected]
with:
persist-credentials: false
submodules: recursive

- name: Lint
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "test-data"]
path = test-data
url = https://github.com/webmachinelearning/test-data
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
### Setup & Run

```sh
> npm install
> git clone --recurse-submodules https://github.com/webmachinelearning/webnn-samples
> cd webnn-samples & npm install
> npm start
```

Expand Down
3 changes: 1 addition & 2 deletions image_classification/mobilenet_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export class MobileNetV2Nchw {
constructor() {
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = 'https://webmachinelearning.github.io/test-data/' +
'models/mobilenetv2_nchw/weights/';
this.weightsUrl_ = '../test-data/models/mobilenetv2_nchw/weights/';
this.inputOptions = {
mean: [0.485, 0.456, 0.406],
std: [0.229, 0.224, 0.225],
Expand Down
3 changes: 1 addition & 2 deletions image_classification/mobilenet_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export class MobileNetV2Nhwc {
constructor() {
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = 'https://webmachinelearning.github.io/test-data/' +
'models/mobilenetv2_nhwc/weights/';
this.weightsUrl_ = '../test-data/models/mobilenetv2_nhwc/weights/';
this.inputOptions = {
mean: [127.5, 127.5, 127.5],
std: [127.5, 127.5, 127.5],
Expand Down
3 changes: 1 addition & 2 deletions image_classification/resnet101v2_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export class ResNet101V2Nhwc {
constructor() {
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = 'https://webmachinelearning.github.io/test-data/' +
'models/resnet101v2_nhwc/weights/';
this.weightsUrl_ = '../test-data/models/resnet101v2_nhwc/weights/';
this.inputOptions = {
mean: [127.5, 127.5, 127.5],
std: [127.5, 127.5, 127.5],
Expand Down
3 changes: 1 addition & 2 deletions image_classification/resnet50v2_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export class ResNet50V2Nchw {
constructor() {
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = 'https://webmachinelearning.github.io/test-data/' +
'models/resnet50v2_nchw/weights/';
this.weightsUrl_ = '../test-data/models/resnet50v2_nchw/weights/';
this.inputOptions = {
mean: [0.485, 0.456, 0.406],
std: [0.229, 0.224, 0.225],
Expand Down
3 changes: 1 addition & 2 deletions image_classification/squeezenet_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export class SqueezeNetNchw {
constructor() {
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = 'https://webmachinelearning.github.io/test-data/' +
'models/squeezenet1.1_nchw/weights/';
this.weightsUrl_ = '../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
3 changes: 1 addition & 2 deletions image_classification/squeezenet_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export class SqueezeNetNhwc {
constructor() {
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = 'https://webmachinelearning.github.io/test-data/' +
'models/squeezenet1.0_nhwc/weights/';
this.weightsUrl_ = '../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
3 changes: 1 addition & 2 deletions lenet/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ function clearResult() {
export async function main() {
drawNextDigitFromMnist();
const pen = new Pen(visualCanvas);
const weightUrl = 'https://webmachinelearning.github.io/test-data/' +
'models/lenet_nchw/weights/lenet.bin';
const weightUrl = '../test-data/models/lenet_nchw/weights/lenet.bin';
const lenet = new LeNet(weightUrl);
try {
let start = performance.now();
Expand Down
3 changes: 1 addition & 2 deletions nsnet2/denoiser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export class Denoiser {
return new Promise((resolve, reject) => {
this.log(' - Loading weights... ');
const start = performance.now();
const weightsUrl = 'https://webmachinelearning.github.io/test-data/' +
'models/nsnet2_nchw/weights/';
const weightsUrl = '../test-data/models/nsnet2_nchw/weights/';
this.nsnet.load(
weightsUrl, this.batchSize, this.frames).then((outputOperand) => {
const modelLoadTime = performance.now() - start;
Expand Down
6 changes: 2 additions & 4 deletions object_detection/ssd_mobilenetv1_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

import {buildConstantByNpy} from '../common/utils.js';

const testDataURL = 'https://webmachinelearning.github.io/test-data';

// SSD MobileNet V1 model with 'nchw' layout, trained on the COCO dataset.
export class SsdMobilenetV1Nchw {
constructor() {
this.model_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = testDataURL + '/models/ssd_mobilenetv1_nchw/weights/';
this.weightsUrl_ = '../test-data/models/ssd_mobilenetv1_nchw/weights/';
// Shares the same bias files with 'nhwc' layout
this.biasUrl_ = testDataURL + '/models/ssd_mobilenetv1_nhwc/weights/';
this.biasUrl_ = '../test-data/models/ssd_mobilenetv1_nhwc/weights/';
this.inputOptions = {
inputLayout: 'nchw',
labelUrl: './labels/coco_classes.txt',
Expand Down
3 changes: 1 addition & 2 deletions object_detection/ssd_mobilenetv1_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ export class SsdMobilenetV1Nhwc {
this.model_ = null;
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = 'https://webmachinelearning.github.io/test-data/' +
'models/ssd_mobilenetv1_nhwc/weights/';
this.weightsUrl_ = '../test-data/models/ssd_mobilenetv1_nhwc/weights/';
this.inputOptions = {
inputLayout: 'nhwc',
labelUrl: './labels/coco_classes.txt',
Expand Down
3 changes: 1 addition & 2 deletions object_detection/tiny_yolov2_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export class TinyYoloV2Nchw {
constructor() {
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = 'https://webmachinelearning.github.io/test-data/' +
'models/tiny_yolov2_nchw/weights/';
this.weightsUrl_ = '../test-data/models/tiny_yolov2_nchw/weights/';
this.inputOptions = {
inputLayout: 'nchw',
labelUrl: './labels/pascal_classes.txt',
Expand Down
3 changes: 1 addition & 2 deletions object_detection/tiny_yolov2_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export class TinyYoloV2Nhwc {
constructor() {
this.builder_ = null;
this.graph_ = null;
this.weightsUrl_ = 'https://webmachinelearning.github.io/test-data/' +
'models/tiny_yolov2_nhwc/weights/';
this.weightsUrl_ = '../test-data/models/tiny_yolov2_nhwc/weights/';
this.inputOptions = {
inputLayout: 'nhwc',
labelUrl: './labels/pascal_classes.txt',
Expand Down
3 changes: 1 addition & 2 deletions style_transfer/fast_style_transfer_net.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export class FastStyleTransferNet {
this.graph_ = null;
this.constPow_ = null;
this.constAdd_ = null;
this.weightsUrl_ = 'https://webmachinelearning.github.io/test-data/' +
'models/fast_style_transfer_nchw/weights/';
this.weightsUrl_ = '../test-data/models/fast_style_transfer_nchw/weights/';
this.inputOptions = {
inputDimensions: [1, 3, 540, 540],
inputLayout: 'nchw',
Expand Down

0 comments on commit 6a19176

Please sign in to comment.