This repository has been archived by the owner on Apr 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds ml5.js v0.3.0 to release (#144)
* set ml5 reference to localhost * Unet example webcam (#120) * added uNet example * rm video from model load * updated UNET example to current UNET implementation * set frameRate to 5 * Tinkering with segmentation example (#121) I am not sure this is better. I do prefer calling `segment()` from `gotResult()` itself, but maybe creating a blank image to eliminate the `draw()` if statement isn't a good idea. * Sentiment example (#118) * added sentiment example * move to p5js * fixed unet sketch at segmentationImage (#122) * add cvae example (#117) * added new cvae example (#123) * handle html elements in p5 and cleaned up functions (#124) * simplify CVAE example (#125) * simplfiying the sentiment example (#126) * simplify unet example (#127) * Update localhost reference and script (#129) * added http://localhost:8080/ml5.js * added all examples with correct http://localhost:8080/ml5.js * changing example to dropdown (#130) * changing example to dropdown * comments * Adds DCGAN example (#138) * initial commit * adds example of dcgan using small face model * use named function for callback * rm console.log * updated className to label (#141) * Feature extractor update to specify number of labels (#142) * added additional label - show how to specify label nums * adds object as input to .classificaiton() * changed version ml5 reference to 0.3.0 * added p5 version 0.8.0
- Loading branch information
Showing
57 changed files
with
432 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,13 @@ | |
<title>Image Classification Example</title> | ||
|
||
|
||
<script src="https://unpkg.com/ml5@0.2.3/dist/ml5.min.js" type="text/javascript"></script> | ||
<script src="https://unpkg.com/ml5@0.3.0/dist/ml5.min.js" type="text/javascript"></script> | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
joeyklee
Author
Contributor
|
||
</head> | ||
|
||
<body> | ||
<h1>Image classification using MobileNet</h1> | ||
<p>The MobileNet model labeled this as <span id="result">...</span> with a confidence of <span id="probability">...</span>.</p> | ||
<img src="images/bird.jpg" id="image" width="400" /> | ||
<img src="images/bird.jpg" id="image" width="400" /> | ||
<script src="sketch.js"></script> | ||
</body> | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<html> | ||
|
||
<head> | ||
<title>ml5 - Sentiment</title> | ||
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js" type="text/javascript"></script> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/addons/p5.dom.min.js"></script> | ||
|
||
<style></style> | ||
|
||
</head> | ||
|
||
<body> | ||
<h1>Sentiment Analysis Demo | ||
</h1> | ||
<h2>Using a pre-trained model from TensorFlow.js Layers trained on short movie review. <br /> | ||
This model is trained to predict the sentiment of a short movie review (as a score between 0 and 1) | ||
</h2> | ||
<h3> | ||
The model is trained using movie reviews that have been truncated to a maximum of 200 words, only the 20000 most used | ||
words in the reviews are used. | ||
</h3> | ||
|
||
<p id='status'></p> | ||
|
||
<div> | ||
<div class="row"> | ||
<p> | ||
<input type="text" style="width: 100%" placeholder="input sentence to analize" id="inputText" /> | ||
</p> | ||
<p> | ||
<button id="submit" class="btn btn-primary">predict sentiment</button> | ||
</p> | ||
<p id="sentiment-res">Sentiment score:</p> | ||
</div> | ||
</div> | ||
|
||
|
||
|
||
<script src="sketch.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
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,17 @@ | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" > | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" > | ||
<meta name="viewport" content="width=device-width, initial-scale=1" > | ||
|
||
<title>CVAE with quick_draw</title> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/addons/p5.dom.min.js"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js" type="text/javascript"></script> | ||
<script src="sketch.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1>Conditional Variational Autoencoder (CVAE) - trained on Google Quick Draw</h1> | ||
</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 @@ | ||
{"model": "models/model.json", "labels": ["airplane", "alarm_clock", "ambulance", "angel", "ant", "anvil", "apple", "axe", "pickup_truck", "laptop", "leaf", "light_bulb", "lighter", "lightning", "lion", "lipstick", "lobster", "lollipop", "mailbox", "megaphone", "mermaid", "microphone", "microwave", "monkey", "moon", "mosquito", "motorbike", "mountain", "mouse", "mouth", "mug", "mushroom", "nail", "necklace", "ocean", "octopus", "onion", "oven", "owl", "panda", "pants", "paper_clip", "parachute", "ice_cream", "jacket", "jail", "kangaroo", "key", "keyboard", "knife"]} |
Binary file not shown.
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 @@ | ||
{"modelTopology": {"keras_version": "2.2.2", "backend": "tensorflow", "model_config": {"class_name": "Model", "config": {"name": "decoder", "layers": [{"name": "latent_input", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 16], "dtype": "float32", "sparse": false, "name": "latent_input"}, "inbound_nodes": []}, {"name": "label", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 51], "dtype": "float32", "sparse": false, "name": "label"}, "inbound_nodes": []}, {"name": "concatenate_2", "class_name": "Concatenate", "config": {"name": "concatenate_2", "trainable": true, "axis": -1}, "inbound_nodes": [[["latent_input", 0, 0, {}], ["label", 0, 0, {}]]]}, {"name": "dense_5", "class_name": "Dense", "config": {"name": "dense_5", "trainable": true, "units": 784, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["concatenate_2", 0, 0, {}]]]}, {"name": "reshape_2", "class_name": "Reshape", "config": {"name": "reshape_2", "trainable": true, "target_shape": [7, 7, 16]}, "inbound_nodes": [[["dense_5", 0, 0, {}]]]}, {"name": "conv2d_transpose_1", "class_name": "Conv2DTranspose", "config": {"name": "conv2d_transpose_1", "trainable": true, "filters": 32, "kernel_size": [3, 3], "strides": [1, 1], "padding": "same", "data_format": "channels_last", "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "output_padding": null}, "inbound_nodes": [[["reshape_2", 0, 0, {}]]]}, {"name": "up_sampling2d_1", "class_name": "UpSampling2D", "config": {"name": "up_sampling2d_1", "trainable": true, "size": [2, 2], "data_format": "channels_last"}, "inbound_nodes": [[["conv2d_transpose_1", 0, 0, {}]]]}, {"name": "conv2d_transpose_2", "class_name": "Conv2DTranspose", "config": {"name": "conv2d_transpose_2", "trainable": true, "filters": 16, "kernel_size": [3, 3], "strides": [1, 1], "padding": "same", "data_format": "channels_last", "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "output_padding": null}, "inbound_nodes": [[["up_sampling2d_1", 0, 0, {}]]]}, {"name": "up_sampling2d_2", "class_name": "UpSampling2D", "config": {"name": "up_sampling2d_2", "trainable": true, "size": [2, 2], "data_format": "channels_last"}, "inbound_nodes": [[["conv2d_transpose_2", 0, 0, {}]]]}, {"name": "conv2d_transpose_3", "class_name": "Conv2DTranspose", "config": {"name": "conv2d_transpose_3", "trainable": true, "filters": 1, "kernel_size": [3, 3], "strides": [1, 1], "padding": "same", "data_format": "channels_last", "activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "output_padding": null}, "inbound_nodes": [[["up_sampling2d_2", 0, 0, {}]]]}], "input_layers": [["latent_input", 0, 0], ["label", 0, 0]], "output_layers": [["conv2d_transpose_3", 0, 0]]}}}, "weightsManifest": [{"paths": ["group1-shard1of1"], "weights": [{"name": "conv2d_transpose_1/kernel", "shape": [3, 3, 32, 16], "dtype": "float32"}, {"name": "conv2d_transpose_1/bias", "shape": [32], "dtype": "float32"}, {"name": "conv2d_transpose_2/kernel", "shape": [3, 3, 16, 32], "dtype": "float32"}, {"name": "conv2d_transpose_2/bias", "shape": [16], "dtype": "float32"}, {"name": "conv2d_transpose_3/kernel", "shape": [3, 3, 1, 16], "dtype": "float32"}, {"name": "conv2d_transpose_3/bias", "shape": [1], "dtype": "float32"}, {"name": "dense_5/kernel", "shape": [67, 784], "dtype": "float32"}, {"name": "dense_5/bias", "shape": [784], "dtype": "float32"}]}]} |
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,44 @@ | ||
// Copyright (c) 2018 ml5 | ||
// | ||
// This software is released under the MIT License. | ||
// https://opensource.org/licenses/MIT | ||
|
||
/* === | ||
ml5 Example | ||
CVAE example using p5.js | ||
=== */ | ||
let cvae; | ||
let button; | ||
let dropdown; | ||
|
||
// function preload() { | ||
// cvae = ml5.CVAE('model/quick_draw/manifest.json'); | ||
// } | ||
|
||
function setup() { | ||
createCanvas(200, 200); | ||
// Create a new instance with pretrained model | ||
cvae = ml5.CVAE('model/quick_draw/manifest.json', modelReady); | ||
|
||
// Create a generate button | ||
button = createButton('generate'); | ||
button.mousePressed(generateImage); | ||
background(0); | ||
} | ||
|
||
function gotImage(error, result) { | ||
image(result.image, 0, 0, width, height); | ||
} | ||
|
||
function modelReady() { | ||
// Create dropdown with all possible labels | ||
dropdown = createSelect(); | ||
for (let label of cvae.labels) { | ||
dropdown.option(label); | ||
} | ||
} | ||
|
||
function generateImage() { | ||
let label = dropdown.value(); | ||
cvae.generate(label, gotImage); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<title>DCGAN Example</title> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/addons/p5.dom.min.js"></script> | ||
|
||
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js" type="text/javascript"></script> | ||
<script src="sketch.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1>DCGAN Example</h1> | ||
</body> | ||
|
||
</html> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Hi guys, the example stopped working with this new library 0.3.0 in my local server. I get a lot of errors on the console about some weird D3D shaders... @joeyklee