Я загружаю модель в tenorflow.js для классификации изображений, но она возвращает: "Unable to get property 'length' of undefined or null reference", message: "Unable to get property 'length' of undefined or null reference", number: -2146823281, stack: "TypeError: Unable to get property 'length' of undefined or null reference at Anonymous function(https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-converter:17:131397)
Браузер, который я использую, - это хром, а модель получена с помощью тензорного потока вpython
Вот мой импорт
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"> </script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-converter">`</script>
Вот мой код
<script>
const MODEL_URL = './tensorflowjs_model.pb'
const WEIGHTS_URL = './weights_manifest.json'
const INPUT_NODE_NAME = 'x';
const OUTPUT_NODE_NAME = 'prediction';
const PREPROCESS_DIVISOR = tf.scalar(255);
const foot=document.getElementById('foot')
async function fun() {
const resultElement=document.getElementById('result')
resultElement.innerText = 'Loading MobileNet...'
const model=await tf.loadFrozenModel(MODEL_URL, WEIGHTS_URL)
const pixels = tf.browser.fromPixels(foot);
var preprocessedInput = tf.div(pixels.asType('float32'), PREPROCESS_DIVISOR);
reshapedInput=tf.image.resizeNearestNeighbor(preprocessedInput,[28,28])
reshapedInput=reshapedInput.reshape([-1,28,28,3])
try{
var output;
output=model.predict({x:reshapedInput,keep_prob:1.0},OUTPUT_NODE_NAME)
console.log(output)
}
catch(err){
console.log(err)
}
console.log("hello")
};
fun()
Где я ошибся?Мне действительно нужна помощь, так как срок скоро наступит ... Спасибо!