Published
Edited
Jun 30, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
tf = require('@tensorflow/tfjs')
Insert cell
tf.version
Insert cell
Insert cell
mobilenet = require('@tensorflow-models/mobilenet@1.0.0')
Insert cell
model = await mobilenet.load(2)
Insert cell
Insert cell
url = "https://source.unsplash.com/400x300/?cat"
Insert cell
image = new Promise((resolve, reject) => {
let image = new Image();
image.crossOrigin = "anonymous";
image.src = url;
image.onload = () => resolve(image);
image.onerror = reject;
})
Insert cell
Insert cell
tensorImage = tf.browser.fromPixels(image)
.resizeBilinear([224,224])
Insert cell
predictions = await model.classify(tensorImage, 5)
Insert cell
Insert cell
predictions.map(d => `${(d.probability * 100).toFixed(2)}% | ${d.className}`)
.join('\n')
.toString()
Insert cell
Insert cell
Insert cell
Insert cell
import {radio} from "@jashkenas/inputs"
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more