MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / loadHostedPretrainedModel

Function loadHostedPretrainedModel

sentiment/loader.js:39–53  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

37 * @return An instance of `tf.Model` with model topology and weights loaded.
38 */
39export async function loadHostedPretrainedModel(url) {
40 ui.status('Loading pretrained model from ' + url);
41 try {
42 const model = await tf.loadLayersModel(url);
43 ui.status('Done loading pretrained model.');
44 // We can't load a model twice due to
45 // https://github.com/tensorflow/tfjs/issues/34
46 // Therefore we remove the load buttons to avoid user confusion.
47 ui.disableLoadModelButtons();
48 return model;
49 } catch (err) {
50 console.error(err);
51 ui.status('Loading pretrained model failed.');
52 }
53}
54
55/**
56 * Load metadata file stored at a remote URL.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected