Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rembg integration #78

Merged
merged 4 commits into from
Jan 11, 2023
Merged

Conversation

graemeniedermayer
Copy link
Contributor

@graemeniedermayer graemeniedermayer commented Jan 5, 2023

The pull request integrates u2-net background removal. So you can remove the background before or after the depth is calculated. It allows you to save the background removed image, and a bk/white mask. default is set to off.

There's one line that might cause trouble on Windows
os.environ["U2NET_HOME"] = str(bg_model_dir)
this line tells rembg where to look for the model.

I haven't fully tested with 3dinpaint or stereo images. An alpha channel is added if using pre-depth calculate which might cause issues with them.

Removing the background before calculating depth for certain images can really improve the details.

depth with background removed
03536-3040755640-_depth

depth with normal background
03525-774995383-_depth

orginal
03535-3040755640-

background removed
depthmap-0029_background_removed

mask (this has an alpha channel if you using light ui this will look white)
depthmap-0005_foreground_mask

There's also u2-net clothing segmentation, but that seems a little out of scope for the moment.

@thygate
Copy link
Owner

thygate commented Jan 6, 2023

Hey, great! Looks like a clean integration, I've not tested it yet, does it work on Windows ?

@graemeniedermayer
Copy link
Contributor Author

graemeniedermayer commented Jan 6, 2023

I don't have a Windows machine. It should work. I just noticed there was quite a few stackoverflow questions about Windows and os.environ , but most are related to permanently setting environment variable (which is not required here).

It should still work without the line. It would just download the models to ~/.u2net folder instead of the webui's /model folder

@thygate
Copy link
Owner

thygate commented Jan 11, 2023

Hey sorry for the delay, I've been a bit preoccupied .. Will merge asap.

@thygate thygate merged commit 367d3db into thygate:main Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants