I don't know javascript and so I wanted to move a HUB model that's only available in JS to a SavedModel format.
I copied this script from a tutorial and tried to add the model.save function, but it's not working.
Here's the script:
<html><head>
<!-- Load the latest version of TensorFlow.js -->
<script src="https://unpkg.com/@tensorflow/tfjs"></script>
<script src="https://unpkg.com/@tensorflow-models/mobilenet"></script>
</head>
<body>
<div id="console"></div>
<!-- Add an image that we will use to test -->
<img id="img" src="https://i.imgur.com/JlUvsxa.jpg" width="227" height="227">
<script>
let net;
async function app() {
console.log('Loading mobilenet..');
// Load the model.
net = await mobilenet.load();
console.log('Successfully loaded model');
// Make a prediction through the model on our image.
const imgEl = document.getElementById('img');
const result = await net.classify(imgEl);
console.log(result);
console.log('Saving mobilenet...');
const saveResults = await net.save('downloads://my-model-1');
console.log('Mobilenet saved');
}
app();
</script>
</body></html>
And here's the error I get:
Uncaught (in promise) TypeError: net.save is not a function
at app (TFjsmodelSaver.html:27)
app @ TFjsmodelSaver.html:27
async function (async)
app @ TFjsmodelSaver.html:19
(anonymous) @ TFjsmodelSaver.html:30
The error clearly says that net.save isn't a function at app, but at the same time net.classify works, and save is in the tfjs: https://js.tensorflow.org/api/0.12.5/#tf.Model.save
What am I missing?
BTW, if there's a way of getting the HUB models in SavedModel without going through this, please point me to it. I'd assume the models were created in TF first and then ported to TFJS, so they might be available somewhere...