uh hello guys welcome to this video So
in this video I will show you how to
remove a background of the image uh
inside Python uh using a free
open-source package which is uh remove
background and using this package you
don't require any API key because most
of the packages require a API key You
need to sign up for a subscription on
the website it cost you money but uh
recently I found out this package it is
completely free you can use it unlimited
number of time so let me show you an
example right here uh we basically
provide a input image uh so we have a
bunch of images present in this folder
so let me take an example so I provide a
input image so right inside this Python
script we provide this
images
/ 1 jpg G So this is my input image I'm
providing this input image So now it
will remove everything It will make this
image transparent Let me execute this
Python script So as soon as I execute
this you will see it will remove the
background And it will create this
output file And you can see the image
background is completely removed And
also you can see the quality of the
rumal It's quite good And uh you can do
this with any image Let's suppose I take
a different
image So once again you
execute So you will see the output once
again for this image You will see
everything in the background Now this
image contains three persons but you
will see all the three persons
background is completely removed So uh
the package name if you go to this
website you just need to install this
first of all So just search
hereg remove background So this is
actually the command here Simply execute
this command to install this module Uh I
have I have already installed it So now
let me show you how to it's very simple
example So first of all we need to
import this package like this We have
this remove function and then we also
need the pillow library which is a image
processing library and then we import
the input
output and then we simply define a
custom function which will be remove
background It takes two arguments First
of all your profile image your input
image So we take this image and then
your output image
So then we define this
function So so here first of all we read
this input image We open this input
image by using the open function So we
simply provide input path read
binary and then we read the input bytes
So we simply say f dot
read So after that we
simply remove the background by using
the remove function which is there in
this module So we simply call this
function simply provide the input
bytes So this will remove the background
Now we just need to save this image file
For saving this image we simply use the
open function of below image
open And lastly we save this image
output image dots
save So that's all So this is a very
simple script We first of all import the
package right here This package contains
this remove function which actually does
the heavy lifting It removes the
background from the image Very simple
module Then we also need the pillow
library So pip install pillow just
install this And then we define this
function We pass two arguments This is
your input image This is your output
image So write in this function we open
the image by using the open function
Then we read each bite store it in this
variable Then we call the remove
function to remove the background And
then lastly we save this image by first
of all opening it putting these output
by it and calling the save function to
save it So just if I execute now you
will see it will create this
result.png file
So removing your background So the image
is created It removed the
background So it's a very handy library
You can make any sort of web application
using this in the browser Just allow
user to upload a image file remove the
background and download this So in the
future I will make some videos about
this how to make web application as well
using this package But I found this
package to be very handy So no need to
subscribe to any model or API key You
can use this uh module completely free
And thank you very much for watching
this video And also check out my website
freemediatools.com
uh which contains thousands of tools