xxxxxxxxxx
26
let classifier;
let doggo;
let prediction = "(nothing yet)";
function preload() {
doggo = loadImage('assets/doggo.jpg');
classifier = ml5.imageClassifier('MobileNet');
}
function setup() {
createCanvas(800, 600);
classifier.classify(doggo, gotResult);
}
function draw() {
background(220);
image(doggo, 0, 0);
textSize(48);
text(prediction, 15, 520);
}
function gotResult(error, results) {
print(results);
prediction = results[0].label;
classifier.classify(gotResult);
}