【发布时间】: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