python:backgroundremover安装及运行中报错的处理(backgroundremover 0.1.9)
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',))
如图:
![](https://img2022.cnblogs.com/blog/1938691/202210/1938691-20221014102003487-717150124.png)
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
如图:
![](https://img2022.cnblogs.com/blog/1938691/202210/1938691-20221014102003505-1563406173.png)
说明:第一次运行命令时会从google的网盘下载需要的模型文件,
我们把它下载到本地后保存即可
3,解决:下载文件
国内有达人提供了一个网盘
提取码:srix
下载完成后,把文件上传到.u2net目录下,如图:
![](https://img2022.cnblogs.com/blog/1938691/202210/1938691-20221014102003487-2124501927.png)
三,测试效果:
直接执行命令
[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
查看原图和生成图:
原图:
![](https://img2022.cnblogs.com/blog/1938691/202210/1938691-20221014102003486-2007931316.jpg)
生成图1(未指定模块):
![](https://img2022.cnblogs.com/blog/1938691/202210/1938691-20221014102003622-1759506512.png)
生成图2(指定模块:u2net_human_seg):
![](https://img2022.cnblogs.com/blog/1938691/202210/1938691-20221014102003620-1580982287.png)
四,查看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:
相关文章
- python抽取指定url页面的title方法
- python支付宝页面扫码支付
- python操作docx学习资料
- python远程登录服务器(paramiko模块安装和使用)
- Python 3.8.8 以及 openpyxl 3.0.7 的下载和安装!
- python django升级安装sqlite3后在python命令行还是显示旧版本的解决办法
- Python模块常用的几种安装方式
- Py之dominate:python的dominate库的简介、安装、使用方法之详细攻略
- Py之Queue:python库之Queue的简介、安装、使用方法之详细攻略
- Py之twilio:python库之twilio的简介、安装、使用方法之详细攻略
- 编程小白想转行互联网,想以python为入口,究竟可不可行?
- 【LeetCode Python实现】19. 删除链表的倒数第 N 个结点(中等)首次 99.5% +
- mac os 安装 python 环境
- 【Python笔记】图片处理库PIL的源代码安装步骤
- Python知识笔记总结
- 纯净Python环境的安装以及配置PyCharm编辑器
- 【Leetcode刷题Python】138. 复制带随机指针的链表
- Python-OpenCV图像处理-08-边沿保留过滤(EPF)
- centos7 安装docker-compose的两种方式(直接下载和通过Python管理器)
- 110 道 Python 面试笔试题超强汇总!
- Python练习4
- Python库安装之requirements.txt, environment.yml