ml5-library
ml5-library copied to clipboard
Can't addImage to Feature Extractor
Hello,
I am working on a simple example to classify Covid lungs based on a Kaggle dataset. I am only using the first 120 images for testing. I have looked through all the bugs, but I still can't seem to figure out how to add a p5 Image to a feature extractor. Currently, I receive the following error:

The following is my code:
let train_covid_images=new Array();
let train_healthy_images=new Array();
let featureExtractor;
let classifier;
// When the model is loaded
function modelLoaded() {
console.log('Model Loaded!');
}
function preload(){
// Initialize a MobileNet as
featureExtractor = ml5.featureExtractor('mobileNet',modelLoaded);
train_covid_images=getImages('images/covid', 'covid', 120);
train_healthy_images=getImages('images/healthy', 'healthy', 120);
}
function setup(){
// Output the current version of ml5 to the console
console.log('ml5 version:', ml5.version);
featureExtractor.addImage(train_covid_images[0], "covid");
featureExtractor.addImage(train_healthy_images[0], "healthy");
}
function getImages(folder, filename, amount){
let images=new Array();
for (let i=0; i < amount; i++){
images[i]=loadImage(`${folder}/${filename}${i}.png`);
console.log(`Loaded ${folder}/${filename}${i}.png`);
}
return images;
}