Check Mobile App
Read now

Clearing background from an image using Machine Learning.

Save

There are many use cases of Machine Learning these days, one of the most usable use case of machine learning is removing background from an Image. Let’s imagine there is a person who is running his online eCommerce website, and everybody knows that product images play an important role to attract customers. But Clicking a high-quality image background less image requires a studio. And Studio costs way too much.

How about an AI-based solution that converts your ordinary, “with-background” image to “background-less image”. Yes, you heard it right for this Tensorflow provided a browser-based technique using which you can remove your image background just like that.

So let’s go and check how this can be done programmatically.

Firstly you need to have a well-trained model, there are two ways to do this.

a) Go for a pre-trained model, there are plenty out there https://github.com/tensorflow/models/blob/master/research/deeplab/g3doc/model_zoo.md

b) Train model your self.

Both of the above-mentioned ways have their own pros and cons. This topic itself is very vast, we will discuss it in another blog.

Then you need to take a camera stream pic a frame from it and use the TensorFlow js API method  “model.execute()” to predict the desired object in that frame and delete or replace other pixels with some color or create a new picture from it and save it.

In the same way, you can use the HTML input type file as an input to the execute method

After that, if you want you can display the same with help of drawImage() on HTML 5 component canvas.

show me code

 

 

OK OK Let’s talk something about CODE

First, you need to load model

 

Then, execute the model of the source input

 

Finally, Utilise this result data and draw on the canvas.

I followed this but can also follow, but this is limited to video-only.

For any query mail us t [email protected]

We will love to hear from you.

Thanks and stay tuned for other ML and AI-based articles.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

Deniel Kerr

Owner and Founder. Opencart

Talk to Sales
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home