| 12 | let objectDetectionModel; |
| 13 | |
| 14 | async 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 | |
| 27 | app.get('/', async (req, res) => { |
| 28 | res.sendFile(path.join(__dirname + '/index.html')); |