Package: backgroundremover
BackgroundRemoverBackgroundRemover is a command line tool to remove background fromimageandvideousing AI, made bynadermxto powerhttps://BackgroundRemoverAI.com. If you wonder why it was made read thisshort blog post.Requirementspython >= 3.6python3.6-dev #or what ever version of python you usetorch and torchvision stable version (https://pytorch.org)ffmpeg 4.4+To clarify, you must install both python and whatever dev version of python you installed. IE; python3.10-dev with python3.10 or python3.8-dev with python3.8How to install torch and fmpegGo tohttps://pytorch.organd scroll down toINSTALL PYTORCHsection and follow the instructions.For example:PyTorch Build: Stable (1.7.1)
Your OS: Windows
Package: Pip
Language: Python
CUDA: NoneTo install ffmpeg and python-devsudo apt install ffmpeg python3.6-devInstallationTo Install backgroundremover, install it from pypipipinstall--upgradepip
pipinstallbackgroundremoverPlease 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 pull them from this repoIt is also possible to run this without installing it via pip, just clone the git to local start a virtual env and install requirements and runpython-mbackgroundremover.cmd.cli-i"video.mp4"-mk-o"output.mov"and for windowspython.exe-mbackgroundremover.cmd.cli-i"video.mp4"-mk-o"output.mov"Installation using Dockergitclonehttps://github.com/nadermx/backgroundremover.gitcdbackgroundremover
dockerbuild-tbgremover.aliasbackgroundremover='docker run -it --rm -v "$(pwd):/tmp" bgremover:latest'Usage as a cliImageRemove the background from a local file imagebackgroundremover-i"/path/to/image.jpeg"-o"output.png"Advance usage for image background removalSometimes it is possible to achieve better results by turning on alpha matting. Example:backgroundremover-i"/path/to/image.jpeg"-a-ae15-o"output.png"change the model for different background removal methods betweenu2netp,u2net, oru2net_human_segbackgroundremover-i"/path/to/image.jpeg"-m"u2net_human_seg"-o"output.png"Videoremove background from video and make transparent movbackgroundremover-i"/path/to/video.mp4"-tv-o"output.mov"remove background from local video and overlay it over other videobackgroundremover-i"/path/to/video.mp4"-tov"/path/to/videtobeoverlayed.mp4"-o"output.mov"remove background from local video and overlay it over an imagebackgroundremover-i"/path/to/video.mp4"-toi"/path/to/videtobeoverlayed.mp4"-o"output.mov"remove background from video and make transparent gifbackgroundremover-i"/path/to/video.mp4"-tg-o"output.gif"Make matte key file (green screen overlay)Make a matte file for premierebackgroundremover-i"/path/to/video.mp4"-mk-o"output.matte.mp4"Advance usage for videoChange the framerate of the video (default is set to 30)backgroundremover-i"/path/to/video.mp4"-fr30-tv-o"output.mov"Set total number of frames of the video (default is set to -1, ie the remove background from full video)backgroundremover-i"/path/to/video.mp4"-fl150-tv-o"output.mov"Change the gpu batch size of the video (default is set to 1)backgroundremover-i"/path/to/video.mp4"-gb4-tv-o"output.mov"Change the number of workers working on video (default is set to 1)backgroundremover-i"/path/to/video.mp4"-wn4-tv-o"output.mov"change the model for different background removal methods betweenu2netp,u2net, oru2net_human_segand limit the frames to 150backgroundremover-i"/path/to/video.mp4"-m"u2net_human_seg"-fl150-tv-o"output.mov"Todoconvert logic from video to image to utilize more GPU on image removalclean up documentation a bit moreadd ability to adjust and give feedback images or videos to datasetsadd ability to realtime background removal for videos, for streamingfinish flask server apiadd ability to use other models than u2net, ie your ownotherPull requestsAcceptedIf you like this libraryGive a link to our projectBackgroundRemoverAI.comor this git, telling people that you like it or use it.Reason for projectWe 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.Referenceshttps://arxiv.org/pdf/2005.09007.pdfhttps://github.com/NathanUA/U-2-Nethttps://github.com/pymatting/pymattinghttps://github.com/danielgatis/rembghttps://github.com/ecsplendid/rembg-greenscreenhttps://superuser.com/questions/1647590/have-ffmpeg-merge-a-matte-key-file-over-the-normal-video-file-removing-the-backghttps://superuser.com/questions/1648680/ffmpeg-alphamerge-two-videos-into-a-gif-with-transparent-background/1649339?noredirect=1#comment2522687_1649339https://superuser.com/questions/1649817/ffmpeg-overlay-a-video-after-alphamerging-two-others/1649856#1649856LicenseCopyright (c) 2021-presentJohnathan NaderCopyright (c) 2020-presentLucas NestlerCopyright (c) 2020-presentDr. Tim ScarfeCopyright (c) 2020-presentDaniel GatisCode Licensed underMIT LicenseModels Licensed underApache License 2.0