stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Feature Request]: Make Extra Networks ignore "empty" folders

Open Aryetis opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What would your feature do ?

I have a lot of models (same happens for LoRa, TI, etc) and am using https://github.com/CurtisDS/sd-model-preview-xd/ to store multiple previews of them. Consequently for each model I have one folder holding multiple pictures + 1 text file and nothing else. Which makes "Extra Networks" add a lot of empty folders on top of my checkpoint cards. I'd like for Extra Networks to add a "Folder button" only if there's some actual model/LoRa/Ti in there. If not possible, an option to turn off those directory altogether :/ would be helpful too. image

Proposed workflow

For solution 1 : nothing to do on the user end For solution 2 : Settings->Extra Networks->Hide Folders : On/Off

Additional information

No response

Aryetis avatar Mar 19 '23 10:03 Aryetis

This probably isn't the right way to do it, but it works, Replace https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/a9fed7c364061ae6efb37f797b6b522cb3cf7aa2/modules/ui_extra_networks.py#L79-L83 with

is_empty = len([item for item in os.listdir(x) if os.path.splitext(item)[1].lower() in [".pt", ".ckpt", ".safetensors"]]) == 0
if not is_empty:
    if not subdir.endswith("/"):
        subdir = subdir + "/"

    subdirs[subdir] = 1

Not putting the images in subfolders should work, too.

missionfloyd avatar Mar 19 '23 22:03 missionfloyd

(sorry for the delay)

Looking for .pt/ckpt/safetensors for is_empty looks like a valid solution to me. (maybe you can do a PR for it ?) Putting all the images out of the folder too.... but then I'm gonna end up with my models dwarfed by dozens if not hundreds of preview pictures. Just ocd stuff I guess.

Aryetis avatar Apr 08 '23 11:04 Aryetis