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

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。