We can create Machine Learning models in a few simple steps using the Teachable Machine
user interfaces.
Click here for a review of some common Machine Learning terminologies.
model
for us.You can use a library like ml5.js
to use the model and perform image classifications in the browser. Below is a code snippet that shows how to use the model to classify the stream of images using the webcam:
// Create a classifier object
classifier = ml5.imageClassifier("./model/model.json", () => {
navigator.mediaDevices
.getUserMedia({ video: true, audio: false })
.then((stream) => {
videoRef.current.srcObject = stream;
videoRef.current.play();
});
});
// Start image classification
classifier.classify(videoRef.current, (error, results) => {
if (error) {
console.error(error);
return;
}
setResult(results);
});
The returned results
array consists of the image classification information with the confidence of matching.
Feel free to check out the princes-finder
project to understand the full usage of ml5.js
with a model created using the Teachable Machine
.
That’s all for now. I hope this shot provides a quick overview of Machine Learning in the browser – thanks for reading!
Feel free to connect with me. You can @ me on Twitter(@tapasadhikary) or follow!
Free Resources