Home Artificial Intelligence Artificial Intelligence with Javascript: A temporary insight for engineers.

Artificial Intelligence with Javascript: A temporary insight for engineers.

2
Artificial Intelligence with Javascript: A temporary insight for engineers.

Okay, so I even have to learn a recent language to implement AI into my web apps?

Well, that will be the case but not . Javascript has an enormous community and it’s around in the net ecosystem. AI is transforming the world and simply because programmers are slow and stick with their proficient language, most web developers are writing applications and don’t have any from .

A sloth doing programming.
Google says programmers and sloths have similar attributes of being lazy and experts at taking things slow.

P.S.: I consider myself a programmer too.

So winding the sarcastic questionnaire part up,

introduced AI in javascript almost 2 years ago and it’s filled with all of the features that the famous library has. It has enabled the javascript community to have all the products of Artificial Intelligence right out of your or .

enables us to make use of available on the web site straight away into our web apps on the client or the server side. Should you go and check the pre-trained models , there are lots of models available to you within the domains of , , , and a few .

Come on, python TensorFlow has a hell lot of models available, you may’t say JavaScript is enough.”

You could hear such sorts of statements from the python devs on the market at all times bragging in regards to the AI part. But wait, there’s a hack.
permits you to convert many of the models available in python to JS and use them as your pre-saved models. is a way that permits you to convert any python model to JS and use it inside your app. And for the safer side, there are not any performance drawbacks in using them after conversion.

I understand, enough talk for . You guys will want to skip all of this and jump right to the code sample (as we at all times do with ).

So for the code part, I might be following with but you guys may also use javascript and its code samples are also available on this .

require("@tensorflow/tfjs-node");
const toxicity = require("@tensorflow-models/toxicity");

async function testTextToxicity() {
const threshold = 0.7; //this defines the extent of accuracy you require
const sentences = ["You're a moron.Go learn something new!"];
// Load the model. Users optionally pass in a threshold and an array of
// labels to incorporate.
const model = await toxicity.load(threshold);

let predictions = await model.classify(sentences);

predictions.forEach((pred) => {
console.log(pred.label, pred.results);
});
}

While you will run this code, you’ll find yourself with something like this.

identity_attack [ {
probabilities: Float32Array(2) [ 0.9920857548713684, 0.007914289832115173 ],
match: false } ]
insult [ {
probabilities: Float32Array(2) [ 0.004494260065257549, 0.995505690574646 ],
match: true } ]
obscene [ {
probabilities: Float32Array(2) [ 0.9910942912101746, 0.008905733935534954 ],
match: false } ]
severe_toxicity [ {
probabilities: Float32Array(2) [ 0.9999923706054688, 0.000007636363989149686 ],
match: false } ]
sexual_explicit [ {
probabilities: Float32Array(2) [ 0.998522937297821, 0.0014770565321668983 ],
match: false } ]
threat [ {
probabilities: Float32Array(2) [ 0.9981972575187683, 0.0018028138438239694 ],
match: false } ]
toxicity [ {
probabilities: Float32Array(2) [ 0.004494187887758017, 0.9955058097839355 ],
match: true } ]

Okay, but what’s the where is it in

Well, there are lots of cases during which we take input from users which can be to be displayed on our webpage equivalent to or on a . Or possibly, a . You may suggest to your users if their message may to the opposite user or filter any content within the comments.

is a model that permits you to and you need to use it to or images that contain in your application.
show some use cases around their models and what else are you able to achieve with the library. DO take a look.!
Here is the of a young guy who used TensorFlow.js to convert images into images that contain higher of the photographs.

Last but not the least, shows the of APIs available which you can use to empower your .

What next? It was all I needed to share and it’s time for you guys to do together with your next app.

. Don’t forget to hit in the event you found this text useful(It helps ) and comment if you’ve gotten any suggestions.

You may connect with me on or follow me on for more.

https://www.linkedin.com/in/m-hassan-yousaf493/

2 COMMENTS

  1. Very nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!

LEAVE A REPLY

Please enter your comment!
Please enter your name here