Hello,
I am started to make a front end application with vue js but have hit a roadblock. I didnt' change any of the tensor flow java script functions that worked before but now I'm getting a weird error. It must be something with Vue js so not sure if you guys have seen this error. Also included the tfjs functions here. It doesn't like the input to predict() i guess. But these worked fine before using vue js which is weird.
tf.loadModel(pathToModels + 'tfjs_model/model.json').then(modelLoad => {
model = modelLoad
try {
model.predict(tf.zeros([1, 224, 224, 3]))
} catch (loadModelError) {
console.log(loadModelError)
}
modelLoaded = true
})
function runMod(imageData) {
var t0 = performance.now()
var image = tf.fromPixels(imageData)
var reshaped = image.expandDims(0).toFloat()
try {
var output
output = model.predict(reshaped.div(tf.scalar(127)).sub(tf.scalar(1)))
var t2 = performance.now()
var index = getMaxIndex(output.dataSync())
document.getElementById('prediction').innerHTML = '<br>' + labels[index]
document.getElementById('confidence').innerHTML =
'<br>Co: ' + output.dataSync()[index]
document.getElementById('timeToRun').innerHTML =
'<br>running model: ' + (t2 - t0) + ' ms'
} catch (runModelError) {
console.log(runModelError)
}
}
Error: Argument 'b' passed to 'div' must be a Tensor or TensorLike, but got e
at convertToTensor (tf...@0.12.0:2)
at e.div (tf...@0.12.0:2)
at tf...@0.12.0:2
at e.tidy (tf...@0.12.0:2)
at Function.e.tidy (tf...@0.12.0:2)
at Object.r.value [as div] (tf...@0.12.0:2)
at e.div (tf...@0.12.0:2)
at runMod (home.vue?3be5:117)
at eval (home.vue?3be5:108)
at e.tidy (tf...@0.12.0:2)
If anyone has any ideas let me know!