-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (27 loc) · 711 Bytes
/
index.js
File metadata and controls
31 lines (27 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
let mobileNet;
let video;
function setup() {
createCanvas(400, 400);
video = createCapture(VIDEO);
background(0);
mobileNet = ml5.imageClassifier('MobileNet', video, modelReady);
}
function draw() {
background(220);
image(video, 0, 0);
}
function modelReady() {
console.log('Model is ready!');
mobileNet.predict(video, getResults);
}
//In ML5, the first argument is always an error
function getResults(error, results) {
if (error) {
console.error(error);
}
else {
console.log(results);
document.getElementById("classify").innerHTML = results[0].label;
mobileNet.predict(video, getResults);
}
}