当前位置:网站首页>Who said you should know PS? This open-source artifact can also be pulled in batch, and the effect is outstanding!
Who said you should know PS? This open-source artifact can also be pulled in batch, and the effect is outstanding!
2022-04-23 11:19:00 【Brother dampness】
Reprint :https://blog.csdn.net/osfront/article/details/114692606
【 Introduction 】: An open source tool for quickly removing background images , After installation and configuration, it can be installed on the server 、 Batch operation of pictures in the command line .
brief introduction
rembg It's using Python Implement a tool for removing background images , requirement Python 3.8 Or later , Support batch operation , It's flexible to use , You can use the command line directly 、 Run as a service 、 stay docker Use in , It can also be called as a library .
Download and install
The source code address of the project is :
https://github.com/danielgatis/rembg
requirement Python 3.8 Or later , Use the following command to install :
pip install rembg
Easy to use
1、 Use on the command line
In the command line, you can edit the server image 、 Local image and the entire folder image operation , as follows :
(1) Operate on remote images :
curl -s http://input.png | rembg > output.png
(2) Operate on local images :
rembg -o path/to/output.png path/to/input.png
(3) Operate on the pictures in the whole folder :
rembg -p path/to/inputs
2、 Use as a service
(1) Start the service
rembg-server
(2) If the picture can be accessed by direct link , You can directly open the following address operation through the browser :
http://localhost:5000?url=http://image.png
You can also use HTML The form is operated by uploading a file :
<form action="http://localhost:5000" method="post" enctype="multipart/form-data">
<input type="file" name="file"/>
<input type="submit" value="upload"/>
</form>
1
2
3
3、 stay docker Use in
stay docker It's also very convenient to use , Run the following command directly :
curl -s http://input.png | docker run -i -v ~/.u2net:/root/.u2net danielgatis/rembg:latest > output.png
4、 Call as library
It's also easy to call directly in a script , First create app.py, The contents are as follows :
import sys
from rembg.bg import remove
sys.stdout.buffer.write(remove(sys.stdin.buffer.read()))
1
2
Run the command again :
cat input.png | python app.py > out.png
Project sample use effect :
Advanced use
Some pictures may use alpha matting Pattern ( That is to use -a -ae 15 Options ) The treatment effect will be more perfect , The order is as follows :
curl -s http://input.png | rembg -a -ae 15 > output.png
The effect comparison is as follows :
Conclusion
remgb That's all for a brief introduction , If you are interested in children's shoes, you can download and install them yourself , More details about , See the project home page .
Open source outpost Everyday sharing is hot 、 Interesting and practical open source projects . Participate in maintenance 10 ten thousand + Star Open source technology repository for , Include :Python、Java、C/C++、Go、JS、CSS、Node.js、PHP、.NET etc. .
版权声明
本文为[Brother dampness]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231115091312.html
边栏推荐
猜你喜欢
赛微微电科创板上市破发:跌幅达26% 公司市值44亿
一道有趣的阿里面试题
C语言之结构体(进阶篇)
升级cpolar内网穿透能获得的功能
R-Drop:更强大的Dropout正则方法
R-drop: a more powerful dropout regularization method
Introduction to neo4j authoritative guide, recommended by Qiu Bojun, Zhou Hongxiang, Hu Xiaofeng, Zhou Tao and other celebrities
语雀文档编辑器将开源:始于但不止于Markdown
分享两个实用的shell脚本
qt 64位静态版本显示gif
随机推荐
MySQL索引优化之分页探索详细介绍
Use of SVN:
PDMS soft lithography process
Share two practical shell scripts
MySQL interview questions explain how to set hash index
得物技术网络优化-CDN资源请求优化实践
Mba-day6 logic - hypothetical reasoning exercises
My creation anniversary
MySQL分区表实现按月份归类
About the three commonly used auxiliary classes of JUC
学习 Go 语言 0x05:《Go 语言之旅》中映射(map)的练习题代码
C语言之结构体(进阶篇)
解读机器人创造出来的艺术
卷积层和池化层总结
MySQL Router重装后重新连接集群进行引导出现的——此主机中之前已配置过的问题
活动进行时! 点击链接加入直播间参与“AI真的能节能吗?”的讨论吧!
How to use JDBC callablestatement The wasnull () method is called to check whether the value of the last out parameter is SQL null
Constraintlayout layout
Structure of C language (Advanced)
Oracle连通性测试小工具