欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

利用Python中?Rembg庫實(shí)現(xiàn)去除圖片背景

 更新時(shí)間:2022年05月30日 11:39:44   作者:Python編程學(xué)習(xí)圈????  
這篇文章主要介紹了利用Python中?Rembg庫實(shí)現(xiàn)去除圖片背景,文章基于?Rembg庫得運(yùn)用展開詳細(xì)介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下

Python 的 Rembg 庫可以去掉圖片中的背景,效果如下:

安裝

CPU版

pip?install?rembg

 GPU版

pip?install?rembg[gpu]

快速上手

命令行調(diào)用

安裝成功后,可以在命令行中調(diào)動(dòng)Rembg。如果只對(duì)單個(gè)圖片進(jìn)行處理

rembg?i?path/to/input.png?path/to/output.png

 對(duì)多個(gè)圖片文件處理(批處理),

rembg?p?path/to/input?path/to/output

在Python中使用

把圖片讀取為二進(jìn)制數(shù)據(jù)

from?rembg?import?remove
#待處理的圖片路徑
input_path?=?'input.png'
#處理后存儲(chǔ)的圖片路徑
output_path?=?'output.png'
with?open(input_path,?'rb')?as?i:
????with?open(output_path,?'wb')?as?o:
????????input?=?i.read()
????????output?=?remove(input)
????????o.write(output)

到此這篇關(guān)于利用Python中?Rembg庫實(shí)現(xiàn)去除圖片背景的文章就介紹到這了,更多相關(guān) Python去除圖片背景內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論