I am in the process of carrying out a small project to learn the alphabet in sign language (and learn p5.js and ml5.js). I got an already trained model that I want to import into my project. The model was in .h5 and I converted it with this command:
$ tensorflowjs_converter --input_format keras model/model.h5 modelJS/
When i load the model with load() i get this error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'load')
let classifier;
function loadModel(){ classifier.load('modelJS/model.json', predict); }
function predict(){ //classifier.classify({image:video},gotResults); }
function setup() {
createCanvas(640, 480); video = createCapture(VIDEO); video.hide();
background(0);
// Load Model
loadModel()
};
function draw(){ image(video, 0, 0, 640, 480); }
As you have it, classifier
is null ("undefined"
). Therefore it doesn't have the property: load()
.
In the ml5js Documentaion classifier
is set to ml5.imageClassifier('MobileNet')
To use a image classification model:
function loadModel(){
classifier = ml5.imageClassifier('modelJS/model.json');
}