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

Function loadModel

firebase-object-detection-node/functions/index.js:14–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12let objectDetectionModel;
13
14async function loadModel() {
15 // Warm up the model
16 if (!objectDetectionModel) {
17 // Load the TensorFlow SavedModel through tfjs-node API. You can find more
18 // details in the API documentation:
19 // https://js.tensorflow.org/api_node/1.3.1/#node.loadSavedModel
20 objectDetectionModel = await tf.node.loadSavedModel(
21 './model/new_object_detection_1', ['serve'], 'serving_default');
22 }
23 const tempTensor = tf.zeros([1, 2, 2, 3]).toInt();
24 objectDetectionModel.predict(tempTensor);
25}
26
27app.get('/', async (req, res) => {
28 res.sendFile(path.join(__dirname + '/index.html'));

Callers 1

index.jsFile · 0.70

Calls 1

predictMethod · 0.45

Tested by

no test coverage detected