lllyasviel / stable-diffusion-webui-forge

GNU Affero General Public License v3.0
8.51k stars 831 forks source link

Checkpoint dropdown in Gradio 4 - Too small, left-aligned and filter area is buggy #1586

Open MNeMoNiCuZ opened 2 months ago

MNeMoNiCuZ commented 2 months ago

When switching to the new version of forge, the checkpoint list has a couple of issues for me when I updated my Forge to the latest version. From this version: image

To this version: image

Problem 1 - Dropdown width

The dropdown is slightly smaller than it was before. I understand the reason, and it is fine, with a few caveats. When the checkpoint dropdown is clicked, the new width is limiting the visibility of long paths. I know there's an option to ignore paths and just show the checkpoint names, but this is not a solution. The paths are there for a reason, to sort the checkpoints properly. I wish to see the paths, but also see the name of the file. With new Forge I cannot.

How it is now: image

How it was before: image

The key issue here is that it no longor shows the full width when the dropdown is clicked. I'm fine with the new shorter width when it's collapsed, for UI-purposes. But not at the cost of readability when clicking the menu.


Problem 2 - Text alignment

There has also been a change in the maximum width of the dropdown menu when it's expanded. This makes the list unreadable when you have long paths. I have extra folders added to the start due to how I have my checkpoint SSDs set up with symlinks and such.

How it is now: image

As you can see, not seeing the filename is troublesome. Ideally this is not needed if we solve Problem 1, but if not, we should right-align this list to make it readable.


Problem 3 - Filter typing

When typing in the dropdown, it used to be that the text you write is shown in the entire dropdown view, this means that you can read what you type.

How it used to be: image

How it is now: image

But as it is right now, I only get the typing area overlapping with the down-arrow on the right side of the drop-down. Thus I cannot see what I type and filter, making this extremely hard to use!

wcole3 commented 2 months ago

Please see comments in PR, I was not able to restore the dropdown expansion tonight, but others might have ideas for the ul.options.

MNeMoNiCuZ commented 2 months ago

@wcole3 While you are in this code, do you see anything that could be behind the very slow speed of the dropdown? It can take up to 10 seconds to load the menu the first time, and then 3 seconds on subsequent times.

It used to be near instant, but with the new Gradio change I notice a big difference in speed.

I have around 1200 checkpoints, but having a drop-down list of 1200 entries should not really be a problem unless the list is doing something weird...

wcole3 commented 2 months ago

I can take a look, I don't see anything in the main_entry Dropdown that jumps out, but there's another Gradio issue that I was going to look at. Can you confirm that if you rename your models/Stable-diffusion folder as a bckup and put a single model in, that the dropdown populates instantly (i.e. is the large number of checkpoints absolutely the issue)?

Btw the PR for the original issue was merged, if you test it out let me know if the dropdown popup list is unwieldy with your directory structure.

MNeMoNiCuZ commented 2 months ago

I can take a look, I don't see anything in the main_entry Dropdown that jumps out, but there's another Gradio issue that I was going to look at. Can you confirm that if you rename your models/Stable-diffusion folder as a bckup and put a single model in, that the dropdown populates instantly (i.e. is the large number of checkpoints absolutely the issue)?

Btw the PR for the original issue was merged, if you test it out let me know if the dropdown popup list is unwieldy with your directory structure.

I can confirm: After renaming the models directory and only keeping 3 models in the new one, if I click on the menu as soon as it refreshes after a cold restart of Forge (new start, refresh page), it takes ~0.3 seconds to get the menu to appear. Very fast, all good.

By re-adding all the models back, it takes 2.5-3 seconds. I double-checked the .safetensors count and it's 983 in total.

Sidenote: My forge reports this towards the end of the launch in the console:

Using online LoRAs in FP16: False
Running on local URL:  http://127.0.0.1:7861

To create a public link, set `share=True` in `launch()`.
Startup time: 48.3s (prepare environment: 5.2s, import torch: 9.0s, initialize shared: 0.1s, other imports: 0.8s, load scripts: 10.0s, initialize extra networks: 19.3s, create ui: 2.7s, gradio launch: 1.3s).
Environment vars changed: {'stream': False, 'inference_memory': 1024.0, 'pin_shared_memory': False}
------------------
[Low VRAM Warning] You just set Forge to use 100% GPU memory (23551.00 MB) to load model weights.
[Low VRAM Warning] This means you will have 0% GPU memory (0.00 MB) to do matrix computation. Computations may fallback to CPU or go Out of Memory.
[Low VRAM Warning] In many cases, image generation will be 10x slower.
[Low VRAM Warning] Make sure that you know what you are testing.
------------------
Environment vars changed: {'stream': False, 'inference_memory': 1024.0, 'pin_shared_memory': False}
------------------
[Low VRAM Warning] You just set Forge to use 100% GPU memory (23551.00 MB) to load model weights.
[Low VRAM Warning] This means you will have 0% GPU memory (0.00 MB) to do matrix computation. Computations may fallback to CPU or go Out of Memory.
[Low VRAM Warning] In many cases, image generation will be 10x slower.
[Low VRAM Warning] Make sure that you know what you are testing.

Not sure if it's relevant or related. Haven't seen that before either.

wcole3 commented 2 months ago

Gotcha, thank you. I think the above is related to the GPU weights slider in the top bar being maxed out. I may be wrong about that, but I don't think it's related to the Dropdown slowdown.

I will try to come up with a test to reproduce the dropdown issue (without downloading 1000 models 😅), though I expect it is coming from Gradio 4 framework changes.

MNeMoNiCuZ commented 2 months ago

There was a similar issue with the checkpoints thumbnails before when having multiple models.

In order to test it, you can make an empty file and name it .safetensors, and then copy that a bunch of times to get to a thousand models. Something like this is meant to work.

wcole3 commented 2 months ago

I tried with 1000 small models and the dropdown seemed pretty instant (<<1s). I tried some variations with longer directory structures as well. Before I move toward trying many actual models, I figured I'd ask if you might have any custom settings or cmdline args you're using that I should try?

MNeMoNiCuZ commented 2 months ago

Interesting! Hmm, I can't think of any particular setting unfortunately.

Here's a screenshot of my "Extra Networks"-settings: image

wcole3 commented 2 months ago

Thank you for the info. Unfortunately, I've not been able to replicate the issue. The only other things I could think of were possible hardware issues, i.e. possibly having the models on an HDD versus a SSD? Or maybe models on a different drive to the python process? But I'm kinda grasping at straws there.

MNeMoNiCuZ commented 2 months ago

Very good suggestions. All models are on the same drive, a WD Black SN850X 4TB Gen 4. Very fast at 7 300 MB/sec reading speeds. Should be fine. Python and Forge is on my other drive of the same type and speed. But yeah, not the same drive.

But with these drives I would not expect it.

The 1000 small models you tested with, were they actual models, or empty files? I was thinking, in case it would have an effect?

Maybe there's a way for you to make 1000 symlinked copies with different names, of a large model, so it thinks it's 1000 large real models? Like SDXL 6gb/model as a base size?