首页 > 解决方案 > 在这种情况下,如何将 Tensorflow.js 与 node.js 一起使用?

问题描述

示例 https://github.com/tensorflow/tfjs-models/tree/master/coco-ssd

从浏览器加载图像,如下所示:

(async () => {
  const img = document.getElementById('img');

  // Load the model.
  const model = await cocoSsd.load();

  // Classify the image.
  const predictions = await model.detect(img);

  console.log('Predictions: ');
  console.log(predictions);
})();

虽然这适用于浏览器,但我想让它在纯 node.js 中运行。有没有办法不创建dom对象(如canvas),使用fs模块加载数据?

标签: javascriptnode.jstensorflow

解决方案


推荐阅读