python:backgroundremover安装及运行中报错的处理(backgroundremover 0.1.9)

一,安装backgroundremover:

1,官方站地址:

https://github.com/nadermx/backgroundremover

2,从命令行安装

[lhdop@blog ~]$ pip3 install backgroundremover

3,安装时报错的处理,参考:

https://blog.imgtouch.com/index.php/2023/06/03/python3-yong-pip-an-zhuang-di-san-fang-ku-shi-bao-cuo/

4,安装pytorch,参考:

https://blog.imgtouch.com/index.php/2023/06/03/linux-an-zhuang-pytorch-python3-6-8-pytorch-1-10-1-cu102/

5,安装ffmpeg,参考:

https://blog.imgtouch.com/index.php/2023/05/22/centos8-shang-an-zhuang-ffmpeg422-bing-zuo-shi-pin-jie-tu/

6,安装python36-devel

[root@blog ~]$  yum install python36-devel

二,运行命令时报错的处理:

1,报错信息

[lhdop@blog ~]$ backgroundremover -i "/home/lhdop/img/a.jpeg" -o "/home/lhdop/img/b.png"

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='drive.google.com', port=443): Max retries exceeded with
url: /uc?id=1ao1ovG1Qtx4b7EoskHXmi2E9rp5CHLcZ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object
at 0x7f00ec2ca828>: Failed to establish a new connection: [Errno 110] Connection timed out',))

如图:

2,查看文档,找到原因:

https://github.com/nadermx/backgroundremover

Please note that when you first run the program, it will check to see if you have the u2net models, if you do not,

it will get them from u2net’s google drive, as they say too here, and in this repo the code that pulls it is here

如图:

说明:第一次运行命令时会从google的网盘下载需要的模型文件,

           我们把它下载到本地后保存即可

3,解决:下载文件

国内有达人提供了一个网盘

链接:https://pan.baidu.com/s/1ZYzV0SYEjlBldsGXIn2IXA

提取码:srix

下载完成后,把文件上传到.u2net目录下,如图:

三,测试效果:

直接执行命令

[lhdop@blog ~]$ backgroundremover -i "/home/lhdop/img/a.jpeg" -o "/home/lhdop/img/b.png"
/home/lhdop/img/b.png

指定模块

[lhdop@blog ~]$ backgroundremover -i "/home/lhdop/img/a.jpeg" -m u2net_human_seg -o "/home/lhdop/img/b2.png"
/home/lhdop/img/b2.png

查看原图和生成图:

原图:

生成图1(未指定模块):

生成图2(指定模块:u2net_human_seg):

四,查看backgroundremover的版本:

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

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

五,查看python及pip的版本: 

查看python的版本:

[lhdop@blog ~]$ python3 --version
Python 3.6.8

查看pip的版本:

[lhdop@blog ~]$ python3 -m pip show pip
Name: pip
Version: 21.3.1
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: distutils-sig@python.org
License: MIT
Location: /usr/local/lib/python3.6/site-packages
Requires:
Required-by:
QR:python:backgroundremover安装及运行中报错的处理(backgroundremover 0.1.9)

python:backgroundremover安装及运行中报错的处理(backgroundremover 0.1.9)》有1条评论

发表回复