AUTOMATIC1111 / stable-diffusion-webui-rembg

Removes backgrounds from pictures. Extension for webui.
MIT License
1.17k stars 173 forks source link

The downloaded onnx for the Remove Background is saved in c:\Users\USERNAME\.u2net\* #2

Open DarkVamprism opened 1 year ago

DarkVamprism commented 1 year ago
Downloading data from 'https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2net.onnx' to file 'C:\Users\USERNAME\.u2net\u2net.onnx'.
100%|###############################################| 176M/176M [00:00<?, ?B/s]
Downloading data from 'https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2netp.onnx' to file 'C:\Users\USERNAME\.u2net\u2netp.onnx'.
100%|#############################################| 4.57M/4.57M [00:00<?, ?B/s]
Downloading data from 'https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2net_human_seg.onnx' to file 'C:\Users\USERNAME\.u2net\u2net_human_seg.onnx'.

I believe these should be saved somewhere in the web-ui folders

CansecoDev commented 1 year ago

Agreed, somewhere like this should work:

extensions/stable-diffusion-webui-rembg/checkpoints

Or even better being able to set it's location with a configuration.

iSupremacy commented 1 year ago

3rd-ed, after all the saving that SD does on your OS Drive/SSD I do not want anymore saving onto it.

maijz128 commented 1 year ago

Change the location of the rembg models.

Models location:

extensions/stable-diffusion-webui-rembg/models

Code change

File: postprocessing_rembg.py

    def process(self, pp: scripts_postprocessing.PostprocessedImage, model, return_mask, alpha_matting, alpha_matting_foreground_threshold, alpha_matting_background_threshold, alpha_matting_erode_size):
        if model == "None":
            return

        import os
        script_dir = os.path.abspath( os.path.dirname( __file__ ) )
        root_dir = os.path.dirname(os.path.normpath(script_dir))
        models_dir = os.path.join(root_dir, "models")
        os.environ["U2NET_HOME"] = models_dir
        # print("U2NET_HOME: " + models_dir)

        .....
Sostay commented 1 year ago

Will this problem be corrected?

h3rmit-git commented 1 year ago

I've opened a Pull Request to fix this issue: https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg/pull/28