pantry icon indicating copy to clipboard operation
pantry copied to clipboard

Stable Diffusion WebUI improvements

Open magnusviri opened this issue 2 years ago • 8 comments

Over the weekend I started using stable-diffusion-webui (sdw) for more than just giggles and here is some feedback on how the tea distribution of sdw can improve. Currently, tea's sdw does this.

  • links ~/.tea/stable-diffusion-webui/v*/lib/extensions to ~/.local/share/stable-diffusion-webui
  • links ~/.tea/stable-diffusion-webui/v*/lib/models/Stable-diffusion to ~/.local/share/models/stable-diffusion
  • links ~/.tea/stable-diffusion-webui/v*/lib/outputs to ~/Documents/Stable Diffusion WEBUI
  • starts with --ui-config-file=/Users/u0076374/.config/stable-diffusion-webui/config.json

I've had to go into ~/.tea/stable-diffusion-webui/v*/lib/ to make many changes. Here's my suggested changes based on what I've had to do.

Change 1

  • Change link ~/.tea/stable-diffusion-webui/v*/lib/extensions to ~/.local/share/stable-diffusion-webui/extensions

The reason for this is because more things need to be linked to user space. See below.

Change 2

  • link ~/.local/share/stable-diffusion-webui/models/Stable-diffusion to ~/.local/share/models/stable-diffusion
  • link ~/.tea/stable-diffusion-webui/v*/lib/models to ~/.local/share/stable-diffusion-webui/models (or something like this)

The reason for the above changes is because the models directory is extremely fluid. There are sdw features that download additional models. Here's a list of the directories that sdw has installed for me based on things I've done.

  • ControlNet (installed the ControlNet extension)
  • LyCORIS (I installed this manually)
  • RealESRGAN (RestoreFaces checkmark)
  • torch_deepdanbooru (I'm not sure how I got this)

Here is an example of a LyCORIS model I had to install manually: john-berkey-style-lycoris

Also, I needed to find the Lora directory to install models there manually. Example: mecha

Change 3

  • link ~/.tea/stable-diffusion-webui/v*/lib/embeddings to ~/.local/share/stable-diffusion-webui/embeddings

The reason for this change is because there are tons of embeddings that can be installed here. Example: https://civitai.com/models/69768/marblingti

Optional change 4

Ideally, sdw can run with the stable-diffusion-webui folder read-only. I haven't really started working on this, but might some day. With that goal, here are other files in it's directory that change when running sdw that could be linked to other locations. I listed this as optional because this might be a major pain.

~/.tea/stable-diffusion-webui/v*/lib/cache.json
~/.tea/stable-diffusion-webui/v*/lib/cache.json.lock
~/.tea/stable-diffusion-webui/v*/lib/config.json
~/.tea/stable-diffusion-webui/v*/lib/interogate
~/.tea/stable-diffusion-webui/v*/lib/detected_maps
~/.tea/stable-diffusion-webui/v*/lib/params.txt
~/.tea/stable-diffusion-webui/v*/lib/tmp
~/.tea/stable-diffusion-webui/v*/lib/styles.csv
~/.tea/stable-diffusion-webui/v*/lib/styles.csv.bak

I don't know what created the interrogate folder. I think it was CLIP or DeepBooru interrogation. Either way, it kind of says to me that it will be futile to try to make the stable-diffusion-webui folder read-only. And of course, I didn't include any pycache directories. What a pain.

magnusviri avatar Jun 20 '23 18:06 magnusviri

Question: when you say "link $x to $y" do you mean ln -s $x $y (impossible at install the way tea currently works, unless we were to write a startup shim that creates those as needed), or do you mean ln -s $y $x, shipping with a bunch of probably broken symlinks? The latter could work but will the folders get created appropriately? The former would generally be corrected with runtime environment variables or a startup script (like whisper.cpp).

jhheider avatar Jun 20 '23 18:06 jhheider

Change link ~/.tea/stable-diffusion-webui/v*/lib/extensions to ~/.local/share/stable-diffusion-webui/extensions

yeah this is what was intended. that it is wrong is a bug. whoops!

link ~/.local/share/stable-diffusion-webui/models/Stable-diffusion to ~/.local/share/models/stable-diffusion

we do this.

link ~/.tea/stable-diffusion-webui/v*/lib/models to ~/.local/share/stable-diffusion-webui/models

can do though sd-webui puts a bunch of stuff in there itself on install so we'll be moving pkg data to userland which we try not to do. Might be a way around that…

~/.tea/stable-diffusion-webui/v*/lib/embeddings to ~/.local/share/stable-diffusion-webui/embeddings

nps

Ideally, sdw can run with the stable-diffusion-webui folder read-only

agreed. We may have to submit patches tho.

mxcl avatar Jun 20 '23 20:06 mxcl

unless we were to write a startup shim that creates those as needed

yep we have a startup shim that does this already.

mxcl avatar Jun 20 '23 20:06 mxcl

I note that sd-webui has a extensions and extensions-builtin folders so you can drop extensions in and not interfere with the builtins. We need to get them to do the same for models.

mxcl avatar Jun 20 '23 20:06 mxcl

link ~/.tea/stable-diffusion-webui/v*/lib/models to ~/.local/share/stable-diffusion-webui/models

can do though sd-webui puts a bunch of stuff in there itself on install so we'll be moving pkg data to userland which we try not to do. Might be a way around that…

actually there’s only:

./VAE-approx/model.pt
./karlo/ViT-L-14_stats.th

i'm not sure if these are actual models or not

mxcl avatar Jun 20 '23 20:06 mxcl

yep we have a startup shim that does this already.

I should just check that before I key up... 🤦

jhheider avatar Jun 20 '23 20:06 jhheider

Sorry it's taken me so long to get back to this. I am debating if I should try to fix this and do a PR.

SDXL has been released and I think it might be better than 1.5.

There are tons of extensions. See the snapshot.

Screenshot 2023-09-20 at 16 01 24

link ~/.tea/stable-diffusion-webui/v*/lib/models to ~/.local/share/stable-diffusion-webui/models

can do though sd-webui puts a bunch of stuff in there itself on install so we'll be moving pkg data to userland which we try not to do. Might be a way around that…

The problem is that so much of stable-diffusion is userland changes. If you aren't familiar with https://civitai.com/ you should look at how customizable this is.

magnusviri avatar Sep 20 '23 22:09 magnusviri

SDXL is the model right? Yeah we should fix this to grab that by default.

mxcl avatar Sep 21 '23 16:09 mxcl