-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
220 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>p5.js iframe</title> | ||
<link rel="stylesheet" href="../style.css"> | ||
</head> | ||
|
||
<body> | ||
<div class="content-container"> | ||
<h1>Image Classification Model</h1> | ||
<p>(Add description.)</p> | ||
<button> | ||
<a href="main.html">Start!</a> | ||
</button> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<script src="https://unpkg.com/ml5@alpha/dist/ml5.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script> | ||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.min.js"></script> --> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.9/dat.gui.min.js"></script> | ||
<link rel="stylesheet" type="text/css" href="../style.css"> | ||
<meta charset="utf-8" /> | ||
</head> | ||
|
||
<body> | ||
<main> | ||
</main> | ||
<div class="content-container"> | ||
<button> | ||
<a href="index.html">Stop</a> | ||
</button> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2019 ml5 | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
/* === | ||
ml5 Example | ||
Image classification using MobileNet and p5.js | ||
This example uses a callback pattern to create the classifier | ||
=== */ | ||
|
||
// Initialize the Image Classifier method with MobileNet. A callback needs to be passed. | ||
let classifier; | ||
|
||
// A variable to hold the image we want to classify | ||
let img; | ||
|
||
// Variables for displaying the results on the canvas | ||
let label = ""; | ||
let confidence = ""; | ||
|
||
function preload() { | ||
classifier = ml5.imageClassifier("MobileNet"); | ||
img = loadImage("images/bird.jpg"); | ||
} | ||
|
||
function setup() { | ||
createCanvas(400, 400); | ||
classifier.classify(img, gotResult); | ||
image(img, 0, 0, width, height); | ||
} | ||
|
||
// A function to run when we get any errors and the results | ||
function gotResult(results) { | ||
// The results are in an array ordered by confidence, print in console | ||
console.log(results); | ||
|
||
// Display the results on the canvas | ||
fill(255); | ||
stroke(0); | ||
textSize(18); | ||
label = "Label: " + results[0].label; | ||
confidence = "Confidence: " + nf(results[0].confidence, 0, 2); | ||
text(label, 10, 360); | ||
text(confidence, 10, 380); | ||
} |
Oops, something went wrong.