banner
andrewji8

Being towards death

Heed not to the tree-rustling and leaf-lashing rain, Why not stroll along, whistle and sing under its rein. Lighter and better suited than horses are straw sandals and a bamboo staff, Who's afraid? A palm-leaf plaited cape provides enough to misty weather in life sustain. A thorny spring breeze sobers up the spirit, I feel a slight chill, The setting sun over the mountain offers greetings still. Looking back over the bleak passage survived, The return in time Shall not be affected by windswept rain or shine.
telegram
twitter
github

3 行代码 5 秒抠图的 AI 神器,根本无需 PS

今天要介绍的这款神工具,只要 3 行代码 5 秒钟就可以完成高精度抠图,甚至都不用会代码,点两下鼠标就完成了。

感受下这款抠图工具抠地有多精细:

image

image

image
这款工具叫:Remove.bg 。基于 Python、Ruby 和深度学习技术开发,通过强大的 AI 人工智能算法实现自动识别出前景主体与背景图,分分钟秒秒钟完成抠图。
网址:https://www.remove.bg/zh

首先是 Python 实现,很简单。

在网站上注册获取 API 后(不想那么麻烦可以用我的),一行代码安装抠图库:

pip install removebg

接下来只需要三行代码就可以完成一张抠图:

from removebg import RemoveBg
rmbg = RemoveBg("WPZ2Q4fraseKfAN9PPxxxxxx", "error.log") # 引号内是你获取的API
rmbg.remove_background_from_img_file("C:/Users/sony/Desktop/1.jpg") 

不仅能抠一张还可以批量抠图(把图片放到一个文件夹就可以了):

from removebg import RemoveBg
import os

rmbg = RemoveBg("WPZ2Q4fraseKfAN9PPxxxxxx", "error.log")
path = '%s/picture'%os.getcwd() #图片放到程序的同级文件夹 picture 里面
for pic in os.listdir(path):
    rmbg.remove_background_from_img_file("%s\%s"%(path,pic))

是不是很爽?

image
默认生成的图片格式尺寸是标准的,每月最多免费处理 50 张照片。如果想生成高清甚至 4K 或者处理更多图片需要付费。
GitHub 库地址:https://github.com/brilam/remove-bg

image
扣完图可以马上换颜色或者背景:

image
除了在线版还可以下载软件到本地使用,支持 Windows / Mac / Linux 三平台。

抠图还有另外一个用途就是抠证件照换背景色了,不会 PS 又不想花钱重照,使用它很快能搞定:

image

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。