八個優秀的開源圖片背景移除程序
圖像背景移除程序通過自動分割圖像中的主體和背景并刪除背景。這個過程涉及利用機器學習算法技術來檢測前景和背景。
刪除圖片背景經常被用于:
- 增強視覺效果,讓觀眾將注意力集中在主體內容上。
- 創建專業圖形:在平面設計、產品攝影和電子商務等場景,可以創建具有透明背景的專業外觀圖像。這允許將對象無縫集成到不同的背景中。
- 優化網頁設計:網頁設計師經常需要刪除圖片背景來創建具有重疊視覺效果的元素。
- 創建營銷材料:在創建營銷材料(如小冊子、橫幅和廣告)的過程中,常常需要移除圖片背景,以便于將圖片的主體放置在各種背景環境中,以達到視覺效果滿足品牌定位。
- 改善產品攝影:電子商務平臺的產品展示圖片往往需要去除干擾并保持統一的背景,來實現一致的產品展示效果。
下面是一些開源的圖片背景移除開源程序。
1.Rembg
源碼:https://github.com/danielgatis/rembg
Rembg是一個可以移除圖片背景的Python開源工具。Rembg還可以用作Python庫,也可以支持GPU,運行起來更加高效。要安裝它,請確保您的系統中安裝了Python,然后運行:
# CPU Support
pip install rembg # for library
pip install rembg[cli] # for library + cli
# GPU Support
pip install rembg[gpu] # for library
pip install rembg[gpu,cli] # for library + cli
使用方式:
# 網絡圖片去除背景
curl -s http://input.png | rembg i > output.png
# 本地圖片去除背景
rembg i path/to/input.png path/to/output.png
2.BackgroundRemover
源碼:https://github.com/nadermx/backgroundremover
官網:https://www.backgroundremoverai.com/
BackgroundRemover是個能夠有效地消除圖像或者視頻背景的命令行工具。這個工具要求安裝python >= 3.6、torch和torchvision穩定版本,以及ffmpeg 4.4+。
安裝backgroundremover:
pip install backgroundremover
移除圖片背景:
backgroundremover -i "/path/to/image.jpeg" -o "output.png"
移除視頻背景:
backgroundremover -i "/path/to/video.mp4" -tv -o "output.mov"
移除視頻背景并轉GIF:
backgroundremover -i "/path/to/video.mp4" -tg -o "output.gif"
還有許多帶參數的用法,有需要不防參考它的開源網站。
3.Imgly
源碼:https://github.com/imgly/background-removal-js
這是一個JavaScript腳本,可以直接在瀏覽器中輕松地從圖像中刪除背景,而不會產生任何額外的成本或隱私問題。
4.Image-Editor
源碼:https://github.com/darshitjain87/Image-Editor
Image-Editor是一個基于AI的照片編輯網站,提供了強大的圖片編輯功能,如:背景更改、顏色調整、裁剪、圖像銳化等。
它基于Python的cv2庫的機器視覺算法實現圖像處理,并利用Mediapipe的selfie_segmentation模型實現在視頻流中的實時去除背景。
5.CarveKit
源碼:https://github.com/OPHoperHPO/image-background-remove-tool
CarveKit是一個使用神經網絡去除高質量圖像中背景的自動化框架。
功能特征:
- 高質量
- 批處理
- 支持NVIDIA CUDA和CPU處理
- FP16推理:快速推理,內存使用率低
- 100%兼容remove.bg的API
- 支持移除頭發中的背景
- 可以輕松與其他代碼集成
安裝CPU版本:
pip install carvekit --extra-index-url https://download.pytorch.org/whl/cpu
安裝GPU版本:
pip install carvekit --extra-index-url https://download.pytorch.org/whl/cu113
6.django_bgRemoverML
源碼:https://github.com/FarjaalAhmad/django_bgRemoverML
這是一個集成Django的機器學習項目,用于從圖像中移除背景。Linux安裝過程如下:
git clone https://github.com/FarjaalAhmad/django_bgRemoverML
cd django_bgRemoverML
python3 -m pip install -r requirements.txt
bash setup.sh
python3 manage.py migrate
python3 manage.py runserver
通過向http://localhost:8000/upload發送POST請求,參數為:image=[BASE64]。
7.Transparent Background
源碼:https://github.com/plemeri/transparent-background
這是一個由InSPyReNet(ACCV 2022)提供并支持的圖片背景刪除工具。可以輕松地從圖像、視頻和其他視覺內容中刪除背景。
8.BG Remover
源碼:https://github.com/developersharif/bgremover-app
下載地址:https://sourceforge.net/projects/bgremover/
官網:https://bgremover.realbrain.cc/
這是一個離線的圖像背景刪除桌面應用程序。它利用最新的機器學習算法在幾秒鐘內提供準確的結果。只需拖放圖像即可輕松編輯圖像,一鍵去除背景。此外,應用程序還包括基本的編輯功能,例如更改圖像背景和顏色。