Difficulty using TensorFlow and MediaPipe with TypeScript in browser

I’m trying to get face detection working in the browser on a local web server (not Node.JS).

import ‘@tensorflow-models/face-detection’ results in this error:

localhost/:1 Uncaught TypeError: Failed to resolve module specifier “@tensorflow-models/face-detection”. Relative references must start with either “/”, “./”, or “…/”.

Using
import “https://cdn.jsdelivr.net/npm/@tensorflow-models/face-detection

does not give a compiler error, but if I add
import * as faceDetection from ‘@tensorflow-models/face-detection’;

it fails to compile.

index.html contains:

There is a problem with the JS face detection MP/TF module. Face mesh works

You are compiling the ts code but are you bundling it?

That error seems to imply that you get the standard unresolved paths from TS, for those to be resolved you need to use ts-loader in webpack or any other bundler.

You wont get that error from the cdn because that is already bundled for you.