I'm following this tutorial: https://codelabs.developers.google.com/codelabs/tfjs-training-classfication/index.html#2
I have set up a local HTTP-server, and that work and the app is running. However, when I try to execute step 3 (Load the data), I get the following error when loading the data:
Uncaught TypeError: Failed to resolve module specifier "@tensorflow/tfjs". Relative references must start with either "/", "./", or "../".
If i comment out the import statment:
import * as tf from '@tensorflow/tfjs';
the page actually loads and shows the sidebar with 16 handwritten digits.
Is TensorFlow loaded, and I do not need this import statement?
Or maybe most important, why does the import not work??
you don't need to import the tfjs libraries if they are loaded as modules
in the html file put:
<html>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<head>
...
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"></script>
<script type="module" src="YOUR_CODE.js"></script>
...
</head>
<body>
...
</body>
</html>
And in YOUR_CODE.js simply put:
async function testModel() {
const model = await tf.loadGraphModel(...);
...
model.execute(pic);
...
}
testModel();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With