python:安装backgroundremover 0.2.4(Python 3.9.16)

一,官方代码及文档:

https://github.com/nadermx/backgroundremover

二, 安装backgroundremover的准备工作

1,安装 pytorch

2,  安装ffmpeg

3,  安装setuptools:

[root@img ~]# pip3 install setuptools

4,  安装python-devel库:

[root@img ~]# yum install python3-devel

三,安装backgroundremover

1,用pip安装

[root@img ~]#  pip3 install backgroundremover

2,安装完成后查看版本:

[lhdop@img .u2net]$ pip3 show backgroundremover
Name: backgroundremover
Version: 0.2.4
Summary: Background remover from image and video using AI
Home-page: https://github.com/nadermx/backgroundremover
Author: Johnathan Nader
Author-email: john@nader.mx
License:
Location: /usr/local/lib/python3.9/site-packages
Requires: certifi, charset-normalizer, ffmpeg-python, filelock, filetype, hsh, idna, more-itertools, moviepy, numpy, Pillow, pymatting, PySocks, requests, scikit-image, scipy, six, torch, torchvision, tqdm, urllib3, waitress
Required-by:

四,下载u2net模型

1,文档地址:

https://github.com/xuebinqin/U-2-Net/blob/master/README.md

如图:

2, 百度网盘的地址:

https://pan.baidu.com/share/init?surl=WjwyEwDiaUjBbx_QxcXBwQ

提取码:

pf9k

谷歌drive的下载地址:

https://drive.google.com/file/d/1ao1ovG1Qtx4b7EoskHXmi2E9rp5CHLcZ/view

3,下载文件后,上传到服务器用户的home目录下的.u2net目录下,如图:

[lhdop@img .u2net]$ ll
total 344344
-rw-rw-r-- 1 lhdop lhdop 176315793 Aug  3 10:35 u2net_human_seg.pth
-rw-rw-r-- 1 lhdop lhdop 176290937 Aug  3 10:35 u2net.pth

说明:刘宏缔的架构森林—专注it技术的博客,
网址:https://imgtouch.com
本文: https://blog.imgtouch.com/index.php/2023/08/03/python-an-zhuang-backgroundremover-2-4-python-3-9-16/
代码: https://github.com/liuhongdi/https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com

四,检测效果

原图:

不指定模块

[lhdop@img ~]$ backgroundremover -i "/home/lhdop/work/background/tx3.webp" -o "/home/lhdop/work/background/b2.png"

指定模块

[lhdop@img .u2net]$ backgroundremover -i "/home/lhdop/work/background/tx3.webp" -m u2net_human_seg -o "/home/lhdop/work/background/b3.png"

五,查看python版本:

[lhdop@img .u2net]$ python --version
Python 3.9.16
QR:python:安装backgroundremover 0.2.4(Python 3.9.16)

发表回复