Load a graph model given a URL to the model definition.
Example of loading MobileNetV2 from a URL and making a prediction with a zeros input:
const modelUrl = 'https://storage.googleapis.com/tfjs-models/savedmodel/mobilenet_v2_1.0_224/model.json';const model = await tf.loadGraphModel(modelUrl);const zeros = tf.zeros([1, 224, 224, 3]);model.predict(zeros).print(); Copy
const modelUrl = 'https://storage.googleapis.com/tfjs-models/savedmodel/mobilenet_v2_1.0_224/model.json';const model = await tf.loadGraphModel(modelUrl);const zeros = tf.zeros([1, 224, 224, 3]);model.predict(zeros).print();
Example of loading MobileNetV2 from a TF Hub URL and making a prediction with a zeros input:
const modelUrl = 'https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/classification/2';const model = await tf.loadGraphModel(modelUrl, {fromTFHub: true});const zeros = tf.zeros([1, 224, 224, 3]);model.predict(zeros).print(); Copy
const modelUrl = 'https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/classification/2';const model = await tf.loadGraphModel(modelUrl, {fromTFHub: true});const zeros = tf.zeros([1, 224, 224, 3]);model.predict(zeros).print();
The url or an io.IOHandler that loads the model.
io.IOHandler
Optional
Options for the HTTP request, which allows to send credentials and custom headers.
Generated using TypeDoc
Load a graph model given a URL to the model definition.
Example of loading MobileNetV2 from a URL and making a prediction with a zeros input:
Example of loading MobileNetV2 from a TF Hub URL and making a prediction with a zeros input: