Skip to content

Commit

Permalink
Hide Layout options (#182)
Browse files Browse the repository at this point in the history
Since current implementation status haven't support both NHWC and NCHW
input layout well, disable layout options temporarily, and target WebNN
CPU backend to NHWC layout models, WebNN GPU backend to NCHW layout
models by default.
  • Loading branch information
Honry authored Sep 27, 2023
1 parent 9ac0836 commit 0b4b3c3
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 31 deletions.
4 changes: 2 additions & 2 deletions face_recognition/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>
</div>
</div>
<div class="row mb-2 align-items-center">
<!-- <div class="row mb-2 align-items-center">
<div class="col-1 wider-col">
<span>Layout</span>
</div>
Expand All @@ -60,7 +60,7 @@
</label>
</div>
</div>
</div>
</div> -->
<div class="row mb-2 align-items-center">
<div class="col-1 wider-col">
<span>FaceRecognition</span>
Expand Down
19 changes: 13 additions & 6 deletions face_recognition/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ $(document).ready(async () => {
}
});

$('#backendBtns .btn').on('change', async () => {
$('#backendBtns .btn').on('change', async (e) => {
if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
if ($(e.target).attr('id').indexOf('cpu') != -1) {
layout = 'nhwc';
} else if (($(e.target).attr('id').indexOf('gpu') != -1)) {
layout = 'nchw';
} else {
throw new Error('Unknown backend');
}
await main();
});

Expand All @@ -60,11 +67,11 @@ $('#fdModelBtns .btn').on('change', async (e) => {
await main();
});

$('#layoutBtns .btn').on('change', async (e) => {
layout = $(e.target).attr('id');
if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
await main();
});
// $('#layoutBtns .btn').on('change', async (e) => {
// layout = $(e.target).attr('id');
// if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
// await main();
// });

// Click trigger to do inference with <img> element
$('#img').click(async () => {
Expand Down
4 changes: 2 additions & 2 deletions facial_landmark_detection/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>
</div>
</div>
<div class="row mb-2 align-items-center">
<!-- <div class="row mb-2 align-items-center">
<div class="col-1 wider-col">
<span>Layout</span>
</div>
Expand All @@ -60,7 +60,7 @@
</label>
</div>
</div>
</div>
</div> -->
<div class="row mb-2 align-items-center">
<div class="col-1 wider-col">
<span>FacialLandmark</span>
Expand Down
19 changes: 13 additions & 6 deletions facial_landmark_detection/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ $(document).ready(async () => {
}
});

$('#backendBtns .btn').on('change', async () => {
$('#backendBtns .btn').on('change', async (e) => {
if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
if ($(e.target).attr('id').indexOf('cpu') != -1) {
layout = 'nhwc';
} else if (($(e.target).attr('id').indexOf('gpu') != -1)) {
layout = 'nchw';
} else {
throw new Error('Unknown backend');
}
await main();
});

Expand All @@ -56,11 +63,11 @@ $('#fdModelBtns .btn').on('change', async (e) => {
await main();
});

$('#layoutBtns .btn').on('change', async (e) => {
layout = $(e.target).attr('id');
if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
await main();
});
// $('#layoutBtns .btn').on('change', async (e) => {
// layout = $(e.target).attr('id');
// if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
// await main();
// });

// Click trigger to do inference with <img> element
$('#img').click(async () => {
Expand Down
4 changes: 2 additions & 2 deletions image_classification/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>
</div>
</div>
<div class="row mb-2 align-items-center">
<!-- <div class="row mb-2 align-items-center">
<div class="col-1 col-md-1">
<span>Layout</span>
</div>
Expand All @@ -60,7 +60,7 @@
</label>
</div>
</div>
</div>
</div> -->
<div class="row align-items-center">
<div class="col col-md-1">
<span>Model</span>
Expand Down
17 changes: 12 additions & 5 deletions image_classification/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ $(document).ready(async () => {

$('#backendBtns .btn').on('change', async (e) => {
if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
if ($(e.target).attr('id').indexOf('cpu') != -1) {
layout = 'nhwc';
} else if (($(e.target).attr('id').indexOf('gpu') != -1)) {
layout = 'nchw';
} else {
throw new Error('Unknown backend');
}
await main();
});

Expand All @@ -60,11 +67,11 @@ $('#modelBtns .btn').on('change', async (e) => {
await main();
});

$('#layoutBtns .btn').on('change', async (e) => {
layout = $(e.target).attr('id');
if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
await main();
});
// $('#layoutBtns .btn').on('change', async (e) => {
// layout = $(e.target).attr('id');
// if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
// await main();
// });

// Click trigger to do inference with <img> element
$('#img').click(async () => {
Expand Down
4 changes: 2 additions & 2 deletions semantic_segmentation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>
</div>
</div>
<div class="row mb-2 align-items-center">
<!-- <div class="row mb-2 align-items-center">
<div class="col-1 col-md-1">
<span>Layout</span>
</div>
Expand All @@ -60,7 +60,7 @@
</label>
</div>
</div>
</div>
</div> -->
<div class="row mb-2 align-items-center">
<div class="col-1 col-md-1">
<span>Model</span>
Expand Down
19 changes: 13 additions & 6 deletions semantic_segmentation/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ $(window).on('load', () => {
loadRenderUI();
});

$('#backendBtns .btn').on('change', async () => {
$('#backendBtns .btn').on('change', async (e) => {
if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
if ($(e.target).attr('id').indexOf('cpu') != -1) {
layout = 'nhwc';
} else if (($(e.target).attr('id').indexOf('gpu') != -1)) {
layout = 'nchw';
} else {
throw new Error('Unknown backend');
}
await main();
});

Expand All @@ -58,11 +65,11 @@ $('#modelBtns .btn').on('change', async (e) => {
await main();
});

$('#layoutBtns .btn').on('change', async (e) => {
layout = $(e.target).attr('id');
if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
await main();
});
// $('#layoutBtns .btn').on('change', async (e) => {
// layout = $(e.target).attr('id');
// if (inputType === 'camera') utils.stopCameraStream(rafReq, stream);
// await main();
// });

// Click trigger to do inference with <img> element
$('#img').click(async () => {
Expand Down

0 comments on commit 0b4b3c3

Please sign in to comment.