Skip to main content

Background remover from image and video

Project description

BackgroundRemover

A command line tool to remove background from video and image, brought to you by BackgroundRemover.app which is an app made by nadermx powered by this tool

background remover video green screen matte key file background remover image

Requirements

  • python 3.6 (only one tested so far but may work for < 3.6)

  • python3.6-dev

  • torch and torchvision stable version (https://pytorch.org)

  • ffmpeg 4.2+

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

sudo apt install ffmpeg python3.6-dev

To install torch:

pip install --upgrade pip
pip install torch==1.7.1+cpu torchvision==0.8.2+cpu -f https://download.pytorch.org/whl/torch_stable.html

Installation

To Install backgroundremover, install it from pypi

pip install backgroundremover

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 u2netp, u2net, 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" -gp 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 u2netp, u2net, 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
  • remove duplicate imports from image and video of u2net models
  • clean up documentation a bit more
  • add ability to adjust and give feedback images or videos to datasets
  • 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

License

Licensed under MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

backgroundremover-0.1.1.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

backgroundremover-0.1.1-py3.6.egg (38.8 kB view details)

Uploaded Egg

File details

Details for the file backgroundremover-0.1.1.tar.gz.

File metadata

  • Download URL: backgroundremover-0.1.1.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.6.13

File hashes

Hashes for backgroundremover-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a0f736c002ef513443028607ebfb09c796308d4bde9199b4c566878b0639b570
MD5 25ff024877659e44deeba3af1b2f77d2
BLAKE2b-256 b89eb7c208a8c17d11e8a73cc3b2422fb54e0c2a0757d2f77437bf26c7de3ac5

See more details on using hashes here.

File details

Details for the file backgroundremover-0.1.1-py3.6.egg.

File metadata

  • Download URL: backgroundremover-0.1.1-py3.6.egg
  • Upload date:
  • Size: 38.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.6.13

File hashes

Hashes for backgroundremover-0.1.1-py3.6.egg
Algorithm Hash digest
SHA256 4e718551144bad517dd14204e896ff9b0dc33ed1793ed489289cd009e5149226
MD5 298151c0effd3a4d3d5da386c70a872e
BLAKE2b-256 c4241ab1941b2fe1994eaa3ba2861301373eecb66743bd91ba5e47c404ba738d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page