Public
Edited
Jan 14, 2023
2 forks
Insert cell
Insert cell
Insert cell
viewof file = Inputs.file({ label: "Image File", accept: ".jpg,.jpeg,.bmp,.png,.gif", required: true })
Insert cell
image = file.image()
Insert cell
Insert cell
viewof table = Inputs.table(output)
Insert cell
Insert cell
p5(sketch => {
let mobileNet
function onModelReady() {
mobileNet.predict(image, onPrediction)
}
function onPrediction(error, results) {
if (error) mutable output = [error]
else mutable output = results
}

sketch.setup = function() {
sketch.createCanvas(width, 0) // hide canvas
sketch.background(0)
mobileNet = ml5.imageClassifier('MobileNet', onModelReady)
};
sketch.draw = function() {
// draw stuff here
}
})
Insert cell
Insert cell
import { p5 } from "@tmcw/p5"
Insert cell
ml5 = import("https://cdn.skypack.dev/ml5@0.1.1").then(x => x.default)
Insert cell
mutable output = []
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