In Operation
Let’s go through an example.
Here’s an image of an adorable ferret snoozing on a warm cozy blanket.
Let’s remove the background from the image. We define the input image with the -i flag and the output image with the -o flag.
$ backgroundremover -i "cute-ferret-is-sleeping.jpg" -o "cute-ferret-is-sleeping.png"
Here’s the generated image.
While the model’s output is good, there’s room for improvement.
Let’s turn on alpha matting with the flags -a and -ai 15.
$ backgroundremover -i "cute-ferret-is-sleeping.jpg" -a -ai 15 -o "cute-ferret-is-sleeping-alpha-matting.png"
Here’s the generated image with alpha matting.
The software isn’t limited to images. It can also remove backgrounds from videos with the ability to make a transparent mov file, overlay it over another video or image. There’s also the option to remove the background from a video and make a transparent GIF. There are various advanced options too such as the ability to change the video’s framerate.
Summary
BackgroundRemover is a very useful tool for removing backgrounds from images and videos. It can use three U2Net models: u2netp, u2net and u2net_human_seg.
The software uses the same AI model as another background remover, Rembg. We received that software in an earlier article.
When we first tried using alpha matting with BackgroundRemover, the command failed to work. This was because the code was using np.int, a deprecated alias for the builtin int, in NumPy. We raised an issue on the project’s GitHub repository. The project’s developer suggested a minor code change, replacing np.int to np.int64 in bg.py. This fixed the issue. A pull request was made within a day of raising the issue!
Website: backgroundremoverai.com
Support: GitHub Code Repository
Developer: Johnathan Nader
License: MIT License
BackgroundRemover is written in Python. Learn Python with our recommended free books and free tutorials.
For other useful open source apps that use machine learning/deep learning, we’ve compiled this roundup.
Pages in this article:
Page 1 – Introduction and Installation
Page 2 – In Operation and Summary