Getting error: Uncaught (in promise) TypeError: tf.browser.fromPixel is not a function
Getting error: Uncaught (in promise) TypeError: tf.browser.fromPixel is not a function
我正在使用 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 方面经验不多。如果有什么我应该补充的,请告诉我
谢谢
根据 documenation,它是 tf.browser.fromPixels
而不是 tf.browser.fromPixel
。
我正在使用 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 方面经验不多。如果有什么我应该补充的,请告诉我
谢谢
根据 documenation,它是 tf.browser.fromPixels
而不是 tf.browser.fromPixel
。