plemeri / transparent-background

This is a background removing tool powered by InSPyReNet (ACCV 2022)
MIT License
791 stars 87 forks source link

Dependencies don't reflect all that are required #73

Closed kwokster10 closed 3 months ago

kwokster10 commented 3 months ago

Hi all, I am currently using this package to remove background on images using the default setting, e.g.:

out = remover.process(img) # default setting - transparent background

The Dependencies however don't actually list all the ones that are required.

In addition to the ones listed these ones also appear required: networkx==3.1 nvidia-cudnn-cu12 nvidia-cufft-cu12 nvidia-curand-cu12 nvidia-cusolver-cu12 nvidia-cusparse-cu12 nvidia-nccl-cu12 nvidia-nvtx-cu12

We aren't using the package with GPU so am wondering if there is a way for some of these dependencies to not be required. Perhaps there's a way to do pip install transparent-background[gpu] for those that need all of that support. The addition of all of those packages greatly increases the amount of disk space required, which could deter others from using this awesome package.

plemeri commented 3 months ago

Hi @kwokster10, I actually thought of removing the dependencies for the gpu support externally, but most users usually want gpu support, so if you want to remove those gpu related packages, please remove torch and torchvision and reinstall the cpu only version after installing our package.

Thank you for your understading.

kwokster10 commented 3 months ago

Thanks @plemeri for the response. I got it working with the suggested --index-url https://download.pytorch.org/whl/cpu after I also specified networkx==3.1 for Python 3.8.x. While testing it out, I noticed it tries to write to /var/www/.transparent-background even though I'm not calling save on the final processed image. Why does it need to do that?

plemeri commented 3 months ago

Seems like you're working with the web server. It usually creates .transparent-background folder under the home directory, but in your case, its /var/www. If it's a problem such as permission issue, I think you might want to modify some of the source code and try to manually install the package. You can start from the hard-coded download path https://github.com/plemeri/transparent-background/blob/00f06d77a978361c66099458b4b73c45ebfd1b22/transparent_background/Remover.py#L43

kwokster10 commented 3 months ago

What does it create the directory for though? Is it for a custom config.yaml, and to determine where to store files if we save? I can fork this and edit, but would it be cleaner to set this up via a config variable (or another kwarg) that the user can set, and that can be added to the docs?

kwokster10 commented 3 months ago

@plemeri if you agree with one of those above approaches, I'd be happen to open a PR with the change. Thanks!

kwokster10 commented 3 months ago

@plemeri I hope you'll consider merging PR: https://github.com/plemeri/transparent-background/pull/75 and releasing a new minor version. Thanks!