ML5 ALIVE!
Tags: javascript, beginners, tensorflow, machinelearning
Published: 2023-10-15 22:32:57

## ML5.js
ML5.js is a machine learning library built on top of TensorFlow.js. It aims to be more approachable than TensorFlow.js. It accomplishes this by abstracting away the higher level mathematics involved in understanding TensorFlow or machine learning at large. 

## Getting Started

```html
<script src="https://unpkg.com/ml5@latest/dist/ml5.min.js"></script>
```
ML5.js does not run in node.js, which the developers hope to remedy now that TensorFlow.js has node support. First thing is first you need to load the script into your html. From there you can start coding in your environment of choice. 

For my adventure into ML5.js, I followed the tutorial for the image classifier and used the MobileNet model.

```js
// Initialize the Image Classifier method with MobileNet
const classifier = ml5.imageClassifier('MobileNet', modelLoaded);

// When the model is loaded
function modelLoaded() {
  console.log('Model Loaded!');
}

// Make a prediction with a selected image
classifier.classify(document.getElementById('image'), (err, results) => {
  console.log(results);
});
```

When the classifier is provided an image, it will send a get request to the model provided and return a result object with the labeled output. 

ML5 comes with many other image based functionality. PoseNet is a model that allows the algorithm to detect the poses of one or multiple people, this data can be used for such things as tracking virtual avatars or motion capture animation. BodyPix is a model that takes an image of a person and differentiate between the background of the image as well as categorize the human form into 24 different body parts. Pix2pix is a model that can take a line art and render it in color. Ml5 also has features for sound recognition and text generators. 

#Machine learning as a creative outlet
{% embed https://www.extrasleepy.com/news/2018/6/23/experimenting-with-ml5js %}

The above link shows another user's adventure with ML5. They created a series of comics called **Land of Lumps**. In the comic, they have two characters- the first representing the user's input and the second representing the machine's response. The short experimental comic shows off the interworking of how the machine interprets language. 

Here is a comic I made using the comic generator provided by the creator, Andrew Kleindolph.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2087gora7586v8c2yyqu.png)

#Conclusion
All in all ML5 is a robust library with many functions that are all simple to learn and easy to implement. This seems to be the dev team's whole mission statement, to make machine learning easy and accessible to the broader community. ML5.js is an open source library build on top of TensorFlow. It abstracts away a lot of the complexity of TensorFlow allowing for it to be accessible to nearly anyone. ML5 also does not have any external dependencies allowing it to be extremely quick to set-up and try out. In conclusion, ML5 is a great library for anyone to try their hands at machine learning.

## Helpful Resources
{% embed https://medium.com/aixdesign/getting-started-with-ml5-js-tutorial-part-i-image-classifier-6d437ec38045 %}

{% embed https://learn.ml5js.org/#/ %}