zl程序教程

您现在的位置是:首页 >  后端

当前栏目

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

Python安装 处理 报错 运行 0.1
2023-09-14 09:01:15 时间

一,安装backgroundremover:

1,官方站地址:
https://github.com/nadermx/backgroundremover
2,从命令行安装
[lhdop@blog ~]$ pip3 install backgroundremover
3,安装时报错的处理,参考:
https://www.cnblogs.com/architectforest/p/16788634.html
4,安装pytorch,参考:
https://www.cnblogs.com/architectforest/p/16788804.html
5,安装ffmpeg,参考:
https://www.cnblogs.com/architectforest/p/12807683.html
6,安装python36-devel
[root@blog ~]$  yum install python36-devel

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

         对应的源码可以访问这里获取: https://github.com/liuhongdi/
         或: https://gitee.com/liuhongdi

说明:作者:刘宏缔 邮箱: 371125307@qq.com

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

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,解决:下载文件
国内有达人提供了一个网盘
提取码: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:

五,查看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: