AUTOMATIC1111 / stable-diffusion-webui-rembg

Removes backgrounds from pictures. Extension for webui.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

DarkVamprism opened this issue · comments

commented
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

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.

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

commented

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)

        .....
commented

Will this problem be corrected?

I've opened a Pull Request to fix this issue: #28