Python implementation of AI automatic matting example analysis

1. Introduction

Use PS for cutout?

Use magic wand and quick selection tool?

What to do if you encounter a complicated background?

Recently discovered a magic tool-Remove Image Background

https://www.remove.bg/zh

It is developed based on Python, Ruby and deep learning technology. It automatically recognizes the foreground subject and background image through a powerful AI artificial intelligence algorithm, and completes the matting in seconds.

There are two simple ways for this cutout tool:

1、 Online cutout

2、 API code cutout

2. Online Cutout

1、 Open the homepage of the remove.bg website, you can upload local pictures, or you can select the URL link of the network picture.

2、 A few seconds after uploading, you can see the transparent image without background.

3、 You can edit the image, add the background of various scenes, or replace it with a solid color background, and then download it.

It also supports client-side Windows, Mac, Linux and PS plug-ins, and can also introduce APIs into its own programs for batch processing.

Three, code cutout

1、 View API key

A registered account is required to obtain the key.

After successful registration, you can log in to view your API key.

The default generated image format size is standard, and up to 50 photos are processed for free each month, and each size does not exceed 25MB.

If you want to generate high-definition or process more pictures, you need to pay (there is no limit on the number of times of online matting).

2、 Install extension library

pip install removebg

3、 Code usage guidelines

https://github.com/brilam/remove-bg

#! /usr/bin/env python3
# - *- coding:utf-8-*-

# Author  : MaYi
# Blog   : http://www.cnblogs.com/mayi0312/
# Date   :2020-03-03
# Name   : test_cutout
# Software : PyCharm
# Note   :AI automatic cutout
from removebg import RemoveBg
rmbg =RemoveBg("YOUR-API-KEY","error.log") #The first quote is the API you obtained
rmbg.remove_background_from_img_file("gitpython.jpg") #The map's address
# Entry function
if __name__ =='__main__':
 pass

operation result:

Four, summary

This article describes two ways:

1、 Online cutout

2、 API code cutout

Different methods can be selected according to needs.

If you want to use it yourself, you can cut out the image online; if you want to batch process, you can try the code to get it.

The above is the whole content of this article, I hope it will be helpful to everyone's study.

Recommended Posts

Python implementation of AI automatic matting example analysis
Basic analysis of Python turtle library implementation
Python implementation of hand drawing effect example sharing
Python analysis of wav files
Analysis of JS of Python crawler
Python implementation of gomoku program
Analysis of Python Sandbox Escape
Analysis of Python object-oriented programming
Analysis of usage examples of Python yield
Detailed implementation of Python plug-in mechanism
Implementation of reverse traversal of python list
Python implementation of IOU calculation case
Python preliminary implementation of word2vec operation
FM algorithm analysis and Python implementation
Python calculation of information entropy example
Analysis of Python conditional control statements
Implementation of python3 registration global hotkey
Implementation of python student management system
Example operation of python access Alipay
Implementation of python gradient descent algorithm
Python tcp transmission code example analysis
Implementation of JWT user authentication in python
Python implementation of intersection and IOU tutorial
Detailed analysis of Python garbage collection mechanism
Implementation principle of dynamic binding of Python classes
Analysis of glob in python standard library
Example of python calculating derivative and plotting
Analysis of common methods of Python multi-process programming
Python implements AI automatic version greedy snake
Method analysis of Python calling C language program
Analysis of common methods of Python operation Jira library
Implementation of Python headless crawler to download files
Implementation of business card management system with python
Example of feature extraction operation implemented in Python
Python writes the game implementation of fishing master
7 features of Python3.9
Python object-oriented example
Python data analysis
Implementation of business card management system based on python
Detailed explanation of the implementation steps of Python interface development
Random command automatic test script | Python implementation under SecureCRT
Example of how to automatically download pictures in python