• 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();

    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();

    Parameters

    • modelUrl: string | IOHandler

      The url or an io.IOHandler that loads the model.

    • Optional options: LoadOptions

      Options for the HTTP request, which allows to send credentials and custom headers.

    • Optional tfio: __module

    Returns Promise<GraphModel>

    Doc

Generated using TypeDoc