Pages

Thursday, 21 October 2021

一键智能抠图程序backgroundremover

 我需要一个能够自动化帮我抠图的工具。

今天要推荐的就是一个智能抠图工具 backgroundremover。

访问网站也可以直接试用抠图效果:https://backgroundremover.app/

backgroundremover 是作者第一个开源项目,所以作者专门写了一篇博客记录了为什么开发这个工具。详情:https://johnathannader.com/my-first-open-source-project/

作者最开始的问题是需要通过邮件发送一些图片,但是因为图片的背景中往往包含一些隐私信息,所以他试着想能不能自动把照片的背景信息自动去除。作者是一个完全的新手,为此他还专门买了两本书,并为了学习机器学习提前补了一些线性代数的知识。后来作者在 u2net 上发现了一个可用的模型,就包装成了一个网站用来自动抠图,并且发送到了 HackerNews 上,没想到如此的受欢迎,并且有人希望作者开源这个项目。因此作者就此走上了开源之路。

开源项目地址:https://github.com/nadermx/backgroundremover

(开源AI去除图像和视频背景-Background Remove

Background Remove,是一个命令行工具,可让你使用 AI 和免费开源的简单命令行界面从图像和视频中删除背景,BackgroundRemoverAI.com 使用机器学习(也称为人工智能)从内容中删除背景,项目开源,带有 API,演示站由nadermx制作,运行要求python> = 3.6版本,感兴趣的同学可以到演示站体验,或者自行搭建。

演示站:https://backgroundremoverai.com/

GitHub地址:https://github.com/nadermx/backgroundremover) 

(移除图像背景和视频背景的工具-Background Remover

Background Remover是一个开源的命令行工具,可借助 AI 能力,快速移除图像和视频背景。基于 nadermx 以及 https://BackgroundRemoverAI.com网站服务。项目为Python编写,遵守MIT开源协议。

环境要求:
python >= 3.6
python3.6-dev #
torch ,torchvision 稳定版本(https://pytorch.org)
ffmpeg 4.4+

使用方法:
本地图片去除背景:
backgroundremover -i "/path/to/image.jpeg" -o "output.png"

视频去除背景,生成透明的mov视频文件:
backgroundremover -i "/path/to/video.mp4" -tv -o "output.mov"

源代码:https://github.com/nadermx/backgroundremover) 

------------

BackgroundRemover lets you Remove Background from images and video with a simple command line interface。

https://backgroundremover.app/

BackgroundRemover 

BackgroundRemover is a command line tool to remove background from video and image, made by nadermx to power https://BackgroundRemover.app. If you wonder why it was made read this short blog post.

Requirements

  • python <= 3.6
  • python3.6-dev #or what ever version of python you using
  • torch and torchvision stable version (https://pytorch.org)
  • ffmpeg 4.4+

How to install torch and fmpeg

Go to https://pytorch.org and scroll down to INSTALL PYTORCH section and follow the instructions.

For example:

PyTorch Build: Stable (1.7.1)
Your OS: Windows
Package: Pip
Language: Python
CUDA: None

To install ffmpeg and python-dev

sudo apt install ffmpeg python3.6-dev

Installation

To Install backgroundremover, install it from pypi

pip install --upgrade pip
pip install 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

Usage as a cli

Image

Remove the background from a local file image

backgroundremover -i "/path/to/image.jpeg" -o "output.png"

Advance usage for image background removal

Sometimes it is possible to achieve better results by turning on alpha matting. Example:

backgroundremover -i "/path/to/image.jpeg" -a -ae 15 -o "output.png"

change the model for diferent background removal methods between u2netpu2net, or u2net_human_seg

backgroundremover -i "/path/to/image.jpeg" -m "u2net_human_seg" -o "output.png"

Video

remove background from video and make transparent mov

backgroundremover -i "/path/to/video.mp4" -tv -o "output.mov"

remove background from local video and overlay it over other video

backgroundremover -i "/path/to/video.mp4" -tov -tv "/path/to/videtobeoverlayed.mp4" -o "output.mov"

remove background from video and make transparent gif

backgroundremover -i "/path/to/video.mp4" -tg -o "output.gif"

Make matte key file (green screen overlay)

Make a matte file for premier

backgroundremover -i "/path/to/video.mp4" -mk -o "output.matte.mp4"

Advance usage for video

Change the framerate of the video (default is set to 30)

backgroundremover -i "/path/to/video.mp4" -fr 30 -tv -o "output.mov"

Change the gpu batch size of the video (default is set to 1)

backgroundremover -i "/path/to/video.mp4" -gb 4 -tv -o "output.mov"

Change the number of workers working on video (default is set to 1)

backgroundremover -i "/path/to/video.mp4" -wn 4 -tv -o "output.mov"

change the model for diferent background removal methods between u2netpu2net, or u2net_human_seg

backgroundremover -i "/path/to/video.mp4" -m "u2net_human_seg"-tv -o "output.mov"

Todo

  • convert logic from video to image to utilize more GPU on image removal
  • clean up documentation a bit more
  • add ability to adjust and give feedback images or videos to datasets
  • add ability to realtime background removal for videos, for streaming
  • finish flask server api
  • add ability to use other models than u2net, ie your own.
  • other

Pull requests

Accepted

If you like this library

Give a link to our project BackgroundRemover.app or this git, telling people that you like it or use it.

Reason for project

We made it our own package after merging together parts of others, adding in a few features of our own via posting parts as bounty questions on superuser, etc. As well as asked on hackernews earlier to open source the image part, so decided to add in video, and a bit more.

References

from https://github.com/nadermx/backgroundremover

No comments:

Post a Comment