xxxxxxxxxx
69
let brain; //create the brain
function setup() {
createCanvas(400, 400);
//STEP 5
// Add data on a mouse Click
//STEP 1
// Create the model
const options = {
inputs: ['x', 'y'], // TODO: support ['x', 'y']
outputs: ['label'], // TODO: support ['label']
debug: true,
task: 'classification'
}
//configure the brain
brain = ml5.neuralNetwork(options);
// Train Model button -this is done using HTML but can be done via DOM lib or alternate GUI lib.
select('#train').mousePressed(trainModel);
background(0);
}
function draw() {
//not needed at moment
}
// Add a data record
function addData() {
//STEP 3
//get the label
//add the data
//STEP 4
// Draw circle to visualize training data
}
//STEP 6
// Train the model
function trainModel() {
//noramlise the data
//Train the model
}
//STEP 7
// When the model is trained
function finishedTraining() {
//classify
}
//STEP 8
// Got a result
function gotResults(error, results) {
//check for errors
// Show classification
select('#classification').html(results[0].label);
//classify again
}