Uncaught (in promise) TypeError: t is not a function

When I added Image to my classifier for training then it throws some exceptions. We are using the Mobilenet model of ml5.js in which when we call train() method.

    let features =  ml5.featureExtractor('MobileNet');
    const classifier = features.classification();
    console.log("setup classifier DONE", classifier);
var img2;
console.log("adding images");
const gorra = new Image();
gorra.src = "https://ml5js.org/docs/assets/img/bird.jpg";
gorra.width = 224;
gorra.height = 224;
console.log("adding images DONE", gorra);

img2 = new Image();
img2.src = "{!$Resource.cat}"
img2.width = 224;
img2.height = 224;
console.log(img2);

var img3;
img3 = new Image();
img3.src = "{!$Resource.car}"
img3.width = 224;
img3.height = 224;
console.log(img3);
console.log("setup classifier");

var img4;
img4 = new Image();
img4.src = "{!$Resource.car1}"
img4.width = 224;
img4.height = 224;
console.log(img4);

console.log("setup classifier");
console.log("adding example image...");
const ex =  classifier.addImage(document.getElementById('imgshow'), "Gorra");
console.log("adding ex image DONE!...", ex);
const ex1 =  classifier.addImage(img2, "Gorra");
console.log("adding ex1 image DONE!...", ex1);
const ex2 =  classifier.addImage(img3, "car");
console.log("adding ex1 image DONE!...", ex2);
const ex3 =  classifier.addImage(img4, "car");
console.log("adding ex1 image DONE!...", ex3);
console.log('claasifier'+classifier);
console.log("Training");
// const trainer ;
setTimeout(function(){ const trainer = classifier.train(); console.log("Training DONE", trainer);}, 30000);

after adding image whenever train() run it throws this error enter image description here which is taking reference of Mobilnet.js library, I have highlighted the line where it causes that error enter image description here

please let me know, how can we resolve this.

#javascript #tensorflow #machine-learning #deep-learning

4 Likes28.00 GEEK