Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

[teachable-machine] Adds ml5.flipImage() #219

Merged
merged 1 commit into from
Oct 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions p5js/TeachableMachine/ImageModel_TM/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let imageModelURL = 'https://storage.googleapis.com/teachable-machine-pubilshed-

// Video
let video;

let flippedVideo;
// To store the classification
let label = "";

Expand All @@ -32,14 +32,15 @@ function setup() {
video.size(320, 240);
video.hide();

flippedVideo = ml5.flipImage(video)
// Start classifying
classifyVideo();
}

function draw() {
background(0);
// Draw the video
image(video, 0, 0);
image(flippedVideo, 0, 0);

// Draw the label
fill(255);
Expand All @@ -50,7 +51,8 @@ function draw() {

// Get a prediction for the current video frame
function classifyVideo() {
classifier.classify(video, gotResult);
flippedVideo = ml5.flipImage(video)
classifier.classify(flippedVideo, gotResult);
}

// When we get a result
Expand All @@ -61,7 +63,7 @@ function gotResult(error, results) {
return;
}
// The results are in an array ordered by confidence.
console.log(results[0]);
// console.log(results[0]);
label = results[0].label;
// Classifiy again!
classifyVideo();
Expand Down