Skip to content

Commit 9f1762c

Browse files
author
b-3-n
committed
Fix standalone example.
1 parent 1e8205e commit 9f1762c

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"webpack-dev-server": "^4.3.0"
1414
},
1515
"dependencies": {
16-
"yoha": "../yoha-v0.0.18.tgz"
16+
"@handtracking.io/yoha": "*"
1717
}
1818
}

example/src/entry.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* The example creates a colored box that can be moved using hand movements. Performing
44
* a pinch or fist gesture changes the color of the cursor.
55
*/
6-
import * as yoha from 'yoha';
6+
import * as yoha from '@handtracking.io/yoha';
77
import {SetCursorColor, SetCursorPosition, SetCursorVisibility, InitializeCursor} from './cursor';
88

99
async function Run() {
1010
// Download models.
11-
const modelFiles = await yoha.DownloadYohaModelFiles(
11+
const modelFiles = await yoha.DownloadMultipleYohaTfjsModelBlobs(
1212
'/box/model.json',
1313
'/lan/model.json',
1414
(rec, total) => {
@@ -27,10 +27,16 @@ async function Run() {
2727
}
2828
const video = yoha.CreateVideoElementFromStream(streamRes.stream);
2929

30+
// Note the 'wasmPath' argument. This has to be in sync with how you serve the respective
31+
// files. See webpack.config.js for an example.
32+
const wasmConfig = {
33+
wasmPaths: './node_modules/@tensorflow/tfjs-backend-wasm/dist/'
34+
};
35+
3036
// Run engine.
3137
// We configure small padding to avoid that users move their hand outside webcam view
3238
// when trying to move the cursor towards the border of the viewport.
33-
yoha.StartWebGlEngine({padding: 0.05}, video, modelFiles, res => {
39+
yoha.StartTfjsWasmEngine({padding: 0.05}, wasmConfig, video, modelFiles, res => {
3440
if (!Math.round(res.isHandPresentProb)) {
3541
SetCursorVisibility(false);
3642
return;

example/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ module.exports = (env) => {
3737
}),
3838
new CopyWebpackPlugin({
3939
patterns: [
40-
{from: 'node_modules/yoha/models/', to: './'},
40+
{from: 'node_modules/@tensorflow/tfjs-backend-wasm/dist/*.wasm'},
41+
{from: 'node_modules/@handtracking.io/yoha/models/', to: './'},
4142
]
4243
})
4344
],

example/yarn.lock

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.6.tgz#d5e0706cf8c6acd8c6032f8d54070af261bbbb2f"
88
integrity sha512-ws57AidsDvREKrZKYffXddNkyaF14iHNHm8VQnZH6t99E8gczjNN0GpvcGny0imC80yQ0tHz1xVUKk/KFQSUyA==
99

10+
"@handtracking.io/yoha@*":
11+
version "1.1.0"
12+
resolved "https://registry.yarnpkg.com/@handtracking.io/yoha/-/yoha-1.1.0.tgz#1b1bedeb7a8297ba1d0d6c14005d29c21d1e0d3a"
13+
integrity sha512-qyLZbHFHm2hP/7YW/Xs6hA8SqEy3ELX5U+aWEmHTjrC7rZxGBSIt7DJcG+JIoXdrp+4XCiscw8ebdO+mG+kIng==
14+
dependencies:
15+
"@tensorflow/tfjs-backend-wasm" "^3.13.0"
16+
"@tensorflow/tfjs-backend-webgl" "^3.12.0"
17+
"@tensorflow/tfjs-converter" "^3.12.0"
18+
"@tensorflow/tfjs-core" "^3.12.0"
19+
1020
"@nodelib/fs.scandir@2.1.5":
1121
version "2.1.5"
1222
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
@@ -36,6 +46,14 @@
3646
"@types/seedrandom" "2.4.27"
3747
seedrandom "2.4.3"
3848

49+
"@tensorflow/tfjs-backend-wasm@^3.13.0":
50+
version "3.13.0"
51+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-wasm/-/tfjs-backend-wasm-3.13.0.tgz#3465c6040542752d2632df7e0c4ac0e5a9ef801a"
52+
integrity sha512-h5kNS4xvljoySzfcFwqbdFB6QZGR06IA9/Xq/PjBeZt18XEoJGqKHbOCYupmUlr5pxo/gnXzPhAC2h4SfZXPXw==
53+
dependencies:
54+
"@tensorflow/tfjs-backend-cpu" "3.13.0"
55+
"@types/emscripten" "~0.0.34"
56+
3957
"@tensorflow/tfjs-backend-webgl@^3.12.0":
4058
version "3.13.0"
4159
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-3.13.0.tgz#f99df51253de21e20dae195991d332195ab30b4b"
@@ -96,6 +114,11 @@
96114
dependencies:
97115
"@types/node" "*"
98116

117+
"@types/emscripten@~0.0.34":
118+
version "0.0.34"
119+
resolved "https://registry.yarnpkg.com/@types/emscripten/-/emscripten-0.0.34.tgz#12b4a344274fb102ff2f6c877b37587bc3e46008"
120+
integrity sha512-QSb9ojDincskc+uKMI0KXp8e1NALFINCrMlp8VGKGcTSxeEyRTTKyjWw75NYrCZHUsVEEEpr1tYHpbtaC++/sQ==
121+
99122
"@types/eslint-scope@^3.7.0":
100123
version "3.7.3"
101124
resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.3.tgz#125b88504b61e3c8bc6f870882003253005c3224"
@@ -2597,11 +2620,3 @@ ws@^8.4.2:
25972620
version "8.4.2"
25982621
resolved "https://registry.yarnpkg.com/ws/-/ws-8.4.2.tgz#18e749868d8439f2268368829042894b6907aa0b"
25992622
integrity sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==
2600-
2601-
yoha@../yoha-v0.0.18.tgz:
2602-
version "0.0.18"
2603-
resolved "../yoha-v0.0.18.tgz#7927350fd35c92acae4cf4f0a35d93c0df267770"
2604-
dependencies:
2605-
"@tensorflow/tfjs-backend-webgl" "^3.12.0"
2606-
"@tensorflow/tfjs-converter" "^3.12.0"
2607-
"@tensorflow/tfjs-core" "^3.12.0"

webpack.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ module.exports = (env) => {
4141
})),
4242
new CopyWebpackPlugin({
4343
patterns: [
44-
// FIXME these wildcards will load some unnecessary stuff right now
4544
{from: 'node_modules/@tensorflow/tfjs-backend-wasm/dist/*.wasm'},
4645
{from: 'models/lan', to: 'lan/'},
4746
{from: 'models/box', to: 'box/'},

0 commit comments

Comments
 (0)