30 November 2019
whoami = DONEimport * as tf from '@tensorflow/tfjs-core';
# Python
import tensorflowjs as tfjs
def train(...):
model = keras.models.Sequential() # for example
#...
model.fit(...)
tfjs.converters.save_keras_model(model, tfjs_target_dir)
# JS
import * as tf from '@tensorflow/tfjs';
const model = await tf.loadModel('https://foo.bar/tfjs_artifacts/model.json');
const example = tf.fromPixels(webcamElement); // for example
const prediction = model.predict(example);
See the keras→js tutorial
<script src="https://unpkg.com/ml5@0.4.3/dist/ml5.min.js"></script>
// Step 1: Create an image classifier with MobileNet
const classifier = ml5.imageClassifier('MobileNet', onModelReady);
// Step 2: select an image
const img = document.querySelector("#myImage")
// Step 3: Make a prediction
let prediction = classifier.predict(img, gotResults);
// Step 4: Do something with the results!
function gotResults(err, results) {
console.log(results);
// all the amazing things you'll add
}
See all the tutorials
word2vec embeddings
face-api.js:https:// reddragon.ai / demo / faceshttps:// reddragon.ai / demo / faces
https:// reddragon.ai / demo / faces
https:// reddragon.ai / demo / faces
https:// reddragon.ai / demo / faces