Today, I want to introduce this amazing tool that can complete high-precision image cutouts in just 3 lines of code and 5 seconds. You don't even need to know how to code, just click the mouse twice and it's done.
Experience how precise this image cutout tool is:
This tool is called Remove.bg. It is developed based on Python, Ruby, and deep learning technology. It uses powerful AI algorithms to automatically identify the foreground subject and background image, allowing you to complete the cutout in minutes or even seconds.
Website: https://www.remove.bg/zh
First, let's start with the Python implementation, which is very simple.
After registering on the website and obtaining the API (or you can use mine if you don't want the trouble), install the cutout library with one line of code:
pip install removebg
Next, you only need three lines of code to complete an image cutout:
from removebg import RemoveBg
rmbg = RemoveBg("WPZ2Q4fraseKfAN9PPxxxxxx", "error.log") # Replace the quotes with your API
rmbg.remove_background_from_img_file("C:/Users/sony/Desktop/1.jpg")
Not only can you cut out a single image, but you can also batch process multiple images (just put the images in a folder):
from removebg import RemoveBg
import os
rmbg = RemoveBg("WPZ2Q4fraseKfAN9PPxxxxxx", "error.log")
path = '%s/picture'%os.getcwd() # Put the images in the program's sibling folder "picture"
for pic in os.listdir(path):
rmbg.remove_background_from_img_file("%s\%s"%(path,pic))
Isn't it great?
The default generated image format and size are standard, and you can process up to 50 photos for free each month. If you want to generate high-definition or even 4K images, or process more photos, you need to pay.
GitHub repository: https://github.com/brilam/remove-bg
After cutting out the image, you can immediately change the color or background:
In addition to the online version, you can also download the software to your local computer, which supports Windows, Mac, and Linux platforms.
Another use of image cutouts is to change the background color of ID photos. If you don't know how to use Photoshop and don't want to spend money on retaking photos, you can quickly do it with this tool: