【问题标题】:Getting error: Uncaught (in promise) TypeError: tf.browser.fromPixel is not a function出现错误:未捕获(承诺中)TypeError:tf.browser.fromPixel 不是函数
【发布时间】:2021-01-30 07:53:32
【问题描述】:

我正在使用 tensorflow js 浏览器端这是依赖项

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js"></script>

在 javascript 中这就是我正在做的事情

let imageModelURL = "https://linktocode.com/model.json"
let htmlVideo = document.getElementById("video");
let model;

async function tensorFlow(){
  console.log("loading model")

  if (document.readyState !== 'complete') {
      console.log("dom not loaded")
    }

  model = await tf.loadLayersModel(imageModelURL);
  classifyVideo();

}
document.addEventListener('DOMContentLoaded', run);
function run()
{
  console.log("DOM Content Loaded")
  tensorFlow();
}

function classifyVideo() {
  console.log("classifying video")
  console.log(tf)
  console.log(tf.browser)
  console.log(tf.browser.fromPixel) //this is undefined

  let example = tf.browser.fromPixel(remoteVideo); //this throws error
  let prediction = model.predict(example);
  console.log(prediction)
  classifyVideo();
}

当执行上述代码时,我得到 Uncaught (in promise) TypeError: tf.browser.fromPixel is not a function 不知道为什么会这样。我在 tensorflow.js 方面经验不多。如果有什么需要补充的请告诉我

谢谢

【问题讨论】:

    标签: javascript tensorflow machine-learning artificial-intelligence tensorflow.js


    【解决方案1】:

    根据documenation,它是tf.browser.fromPixels 而不是tf.browser.fromPixel

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-05
      • 1970-01-01
      • 2021-05-02
      • 2021-04-11
      • 1970-01-01
      • 2018-07-04
      • 1970-01-01
      • 2017-06-25
      相关资源
      最近更新 更多