Hi,
I’m sure I’m missing something simple, but the documentation here implies that I should be able to run the MediaPipeHands model in-browser using tags. Unfortunately, I’m getting a TypeError when I try to create and run a basic demo.
Here is the code I have:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TF Demo</title>
</head>
<body>
<!-- Require the peer dependencies of hand-pose-detection. -->
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/hands"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core"></script>
<!-- You must explicitly require a TF.js backend if you're not using the TF.js union bundle. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgl"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection"></script>
<script>
(async function init() {
const model = handPoseDetection.SupportedModels.MediaPipeHands;
const detectorConfig = {
runtime: 'mediapipe',
solution: 'https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection'
};
detector = await handPoseDetection.createDetector(model, detectorConfig);
})();
</script>
</body>
</html>
When I try to open this in Chrome or Firefox I get the following error:
Uncaught (in promise) TypeError: e.Hands is not a constructor
t https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
l https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
s https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
s https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
o https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
o https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
l https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
createDetector https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
s https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
s https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
o https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
o https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
createDetector https://cdn.jsdelivr.net/npm/@tensorflow-models/hand-pose-detection:17
init http://127.0.0.1:5500/index.html:26
<anonymous> http://127.0.0.1:5500/index.html:27
hand-pose-detection:17:2504
init http://127.0.0.1:5500/index.html:26
AsyncFunctionThrow self-hosted:699
(Async: async)
<anonymous> http://127.0.0.1:5500/index.html:27
What am I missing? Is it not actually possible to run TFjs this way?