stable-diffusion-webui
stable-diffusion-webui copied to clipboard
[Feature Request]: LORA-extraction from checkpoint/safetensor models
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 ?
Edit: Please upgrade AUTOMATIC1111 web-UI to include an extension for either the sashaok123 script or the Kohya script for extracting LORAs from checkpoint models (and maybe safetensors models too). Links to both of these scripts are in comments. I'm not sure which would be better to implement
This is a script made by sashaok123 on github that extracts a LORA model from a checkpoint model (and maybe safetensor model too, but this needs to be verified), often saving multiple gigabytes of space on computer storage, but at the price of a very minor amount of lost detail. I believe this would be a massive development to further this technology since it seems we are moving towards incorporating the use of LORAs much more rapidly as a new type of standard model for Stable Diffusion.
"The script is quite simple, run it (independently from the web-UI at the moment) and follow the instructions that will appear. I warn you that when extracting the LoRA model from the checkpoint, the processor and RAM are heavily loaded. The video (graphics) card is not used at all during extraction." The creator said they keep 10GB of RAM free for it, but the more RAM allocated for the process means the better quality of LORA will be extracted.
Here is a link to a comment thread on civitai where the creator of the script stated how to run it and some more details about how it works: https://civitai.com/models/6461/ayonimixv3lora300?commentId=18473&modal=commentThread
I am not the creator of this script, nor do I know the deep details on how exactly it works, but I got permission from them to request this feature be added.
Proposed workflow
If you think of a better and more intuitive way to implement this, please do. I am not a web designer or UI designer and this could be very unintuitive...
To download it:
- Go to the "Extensions" tab at the top of the AUTOMATIC1111 web-UI
- Put a check in a checkbox next to this extension, which can be named something like "ckpt/safetensor to LORA-extraction"
- Download and install and restart the web-UI like with any other extension
To use it:
- Either in a new tab at the top of the screen titled something like "Extract LORA" or somewhere inside the "Additional Networks" tab, you can access this process
- In this tab, select the checkpoint (ckpt) or safetensor file that you want to extract a LORA from out of a dropdown menu
- You can optionally change the name, otherwise it would stay the same as the original model, but with "LORA" at the end of the name
- You can optionally change the destination of the output file. Otherwise, it would default to the LORA folder in additional-networks folder in files
- Click "Extract LORA" and the Stable Diffusion will begin the extraction process
(Please include a large note or warning somewhere on the page to tell people that this process is heavy on the processor and RAM of their computer. It is recommended to have a certain amount of RAM available, but the more RAM they have available means the better the final LORA output will be. I do not know the minimum amount of RAM needed for this process, but it is below 10GB)
Additional information
Here is the link to the LORA-extraction script on github by sashaok123: https://github.com/sashaok123/LoRA-EXTRACTOR
I have received their approval to request this feature addition. Also, here is their civitai account with lots of LORAs extracted from a few popular models as well as new LORAs: https://civitai.com/user/Kappa_Neuro
Could you attribute this feature to them in the credit area on the github and link to one (probably the civitai link if only one) or both of these links? I'm sure they would appreciate it. Thank you!
Here is the link to the LORA-extraction script on github by sashaok123: https://github.com/sashaok123/LoRA-EXTRACTOR
This would be awesome! I'm very much supporting the request 🙏🏼
following
following
The chosen one who will implement dis, would become a hero.
Awesome idea. Someone please implement this.
Id like this, training dreambooth and then extracting lora can get pretty good results, better than textual inversion when it comes to likeness and the filesize is not big , some even use 9MB lora weights
Very late to this party, but I hope this is being considered. I'm on a Mac and can't run kohya_ss GUI, so this would be SUCH a convenient additional feature for SD
https://civitai.com/models/6461/ayonimixv3lora300?commentId=18473&modal=commentThread
Same here, it'd be nice to make smaller LORA and stuff too
I cannot find the Additonal Nework tab after the first 3 steps. Did I miss something?
I'm going to close this because there is already several tools to do this, including one from a repo Auto personally recommends. https://github.com/kohya-ss/sd-scripts/blob/main/networks/extract_lora_from_models.py
The training tab and related features to it is also planned to be deprecated at some point, and this is something that would fall into that category. https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/11857#discussioncomment-6480804