3

I want to load a model from an url in node.

This works in the broser:

mobileNet = await tf.loadModel('https://storage.googleapis.com/tfjs-models/tfjs/mobilenet_v1_0.25_224/model.json');

But not in node

Error: browserHTTPRequest is not supported outside the web browser without a fetch polyfill

I can do get request with node like this:

const https = require('https');
https.get(mobileNetUrl, (res) => {
    ...
});

The get request returns an Object with a modelTopology and a weightManifest. How could I create a model from it?

0

1 Answer 1

3

You need to add this line to your code

global.fetch = require('node-fetch');

tf.loadModel uses fetch under the hood. But fetch is not natively supported in nodeJs. That is why the pollyfill should be imported.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.