But that is not the case. You yourself being a machine learning...a front-end engineer can integrate machine learning capabilities without having to go in the loop or learning a new language stack altogether. And how you can accomplish that is with the help of a plethora of open source machine learning libraries for Javascript that are available for you to use with your React application.
So whether it's one of the most popular open source Javascript based machine learning libraries TensorFlow.js or ONNX.js or even some of the more upcoming frameworks and libraries such as Transformers.js that allow you to add the capability of very large machine learning models directly in your browser with the help of Javascript, which you can of course include in your React app.
And there are five different reasons why you should actually run machine learning model inference on React and in your front end apps. And primarily that's due to five things. So the first one is the privacy. When you use these machine learning based models and you run these inference on the browser itself, that is a lot more private and it's a lot more better privacy. Because you're not doing the inference of machine learning on a dedicated server. That also is a lot less costly because you don't have to maintain dedicated servers. So you can do all of these particular inference, machine learning inference directly in the browser and you also end up getting lower cost and lower latency as well.
And the reach and scale with which you can actually build and serve these applications it's a lot more now. Also one important thing to consider over here is that the way that we are able to actually do this inference on the browser is with the help of being able to leverage the use of your system hardware such as CPU, GPUs, because all these different libraries that we discussed come with support for technologies such as WebAssembly, WebGPU, which allow to improve the performance of your browser based applications with the help of different technologies such as WebGL or of course with your system hardware being utilized to be able to run these inference or training directly in the browser. So the idea is that, with the help of these particular libraries, you can use them without having to learn about something like Python and in fact, in a lot of use cases you get better performance with JavaScript as compared to even something with Python in a lot of these particular models, because they are more optimized for JavaScript and in some cases JavaScript is actually faster.
And one demo that I'll be showing to all of you is built with the help of TensorFlow.js, which is of course a completely open source machine learning library that is available for anyone to use, and we'll be using a pre-built machine learning model that we'll be utilizing for our app. So there are a lot of pre-built applications or models that are already available with TensorFlow and similarly for other libraries that we have already covered, including for human-based, text-based, sound-based, and others as well. And the one that we'll use is the CocoaSSIST model. So the CocoaSSIST model is a very famous, well-known model for being able to classify your images. So it's going to be a very straightforward step. We'll load an image, load the actual machine learning model, and get predictions. For example, over here we are predicting some dogs inside of an image that we upload, and we get a bounding box with a result of the classified image and the tag that it gets classified with. So for our demo, we'll be installing these particular packages. So it's going to be the TensorFlow.js itself and the CocoaSSIST model. And you can import these models directly in React by using this particular way. Then we will be loading these models in our React app and wait for the model to load completely. So in this case, we are going to be loading the CocoaSSIST model. Now once the model has been loaded, we can actually go ahead and write the predictions for being able to predict based on a particular video source. So let's say I open my webcam and I try to detect what is in the video source and I will be able to very easily do that with the help of the predictions function. Now in order to basically get started with it, let's see how that actually looks. So I'll go to my VS Code and this is my React app.
Comments