• Creates an IOHandler that loads model artifacts from user-selected files.

    This method can be used for loading from files such as user-selected files in the browser. When used in conjunction with tf.loadLayersModel, an instance of tf.LayersModel (Keras-style) can be constructed from the loaded artifacts.

    // Note: This code snippet won't run properly without the actual file input
    // elements in the HTML DOM.

    // Suppose there are two HTML file input (`<input type="file" ...>`)
    // elements.
    const uploadJSONInput = document.getElementById('upload-json');
    const uploadWeightsInput = document.getElementById('upload-weights');
    const model = await tf.loadLayersModel(tf.io.browserFiles(
    [uploadJSONInput.files[0], uploadWeightsInput.files[0]]));

    Parameters

    • files: File[]

      Files to load from. Currently, this function supports only loading from files that contain Keras-style models (i.e., tf.Models), for which an Array of Files is expected (in that order):

      • A JSON file containing the model topology and weight manifest.
      • Optionally, one or more binary files containing the binary weights. These files must have names that match the paths in the weightsManifest contained by the aforementioned JSON file, or errors will be thrown during loading. These weights files have the same format as the ones generated by tensorflowjs_converter that comes with the tensorflowjs Python PIP package. If no weights files are provided, only the model topology will be loaded from the JSON file above.

    Returns IOHandler

    An instance of Files IOHandler.