Comments (4)
Just check the code. The gist of the algorithm is xuebinqin/U-2-Net
.
backgroundremover/src/backgroundremover/bg.py
Lines 183 to 189 in 5cfa5bd
- a segmentation mask is predicted with a neural network:
The first models (u2netp
and u2net
) are for salient object detection, and the other (u2net_human_seg
) is for human segmentation.
backgroundremover/src/backgroundremover/u2net/detect.py
Lines 20 to 30 in 5cfa5bd
- then alpha-matting cut-out is performed using:
- either a "naive" approach (just use the mask!),
- or a higher-level one: morphological operations, followed by:
- Germer et al. "Fast multi-level foreground estimation", 2020,
- as implemented by the authors themselves in
pymatting/pymatting
aspymatting.foreground
.
backgroundremover/src/backgroundremover/bg.py
Lines 158 to 161 in 5cfa5bd
backgroundremover/src/backgroundremover/bg.py
Lines 132 to 133 in 5cfa5bd
On a side-note, the README was updated 3 days ago (5cfa5bd) with a link to a little blogpost mentioning U2-Net, which was posted two days before the OP asked the question. So the information was already available through this other mean but not as easily available as it is now.
Finally, I will mention a competitor to U2-Net, which is MODNet. I don't know which performs better.
- Ke et al. "Is a Green Screen Really Necessary for Real-Time Portrait Matting?", 2020
ZHKKKe/MODNet
- the official online demo
from backgroundremover.
I assume it scans the image for a human, segments the image in parts which are connected to the potentially moving human in the foreground and other parts will be the background via exclusion. Otherwise it would probably not work for animated backgrounds.
Another approach would be using an additional image source of the background only to help separating between background and foreground via differences to the background source. But because there is no such additional source given as parameter in the examples, that doesn't work here.
The most consistent way would probably be an additional input from a depth sensor/camera. So there wouldn't be the requirement of a human or specific object to be recognized in the foreground. However then you had bigger hardware limitations for users of the software. ^^'
from backgroundremover.
Thank you @woctezuma I will also add, that the video part, has a whimsical with a video made by https://github.com/ecsplendid whom is the developer who's code I modified to get it working on this, which all came from this issue in the rembg library
from backgroundremover.
@woctezuma I'll also put on the todo to be able to import in different models.
from backgroundremover.
Related Issues (20)
- Great god, come on!
- How to use in a Android App ? HOT 1
- How to use as a library ? HOT 2
- Does this software support batch JPG processing? HOT 1
- Anyone can help? thanks HOT 6
- Error initializing filter 'alphamerge' with args 'shortest=1' HOT 3
- May I ask how to make a model
- Video removal produces mask only? HOT 4
- transparent mov not created HOT 1
- video over image not working HOT 1
- Server Requirements? HOT 2
- Mismatch Between GitHub and PyPI Versions of backgroundremover v0.2.7 HOT 3
- Solved - ValueError: invalid literal for int() with base 10: '9222,\n\n' HOT 2
- API rotates image HOT 6
- It doesn't use GPU and runs much slower on Intel CPU
- How to start http server. ?
- Some elements of the background of the image are lost HOT 1
- API Usage Problem
- HEIC support
- The backgound still exists in my generated video. OS is ubuntu 22.04 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backgroundremover.