r/StableDiffusion • u/use_excalidraw • Jan 15 '23
Tutorial | Guide Well-Researched Comparison of Training Techniques (Lora, Inversion, Dreambooth, Hypernetworks)
819
Upvotes
r/StableDiffusion • u/use_excalidraw • Jan 15 '23
34
u/use_excalidraw Jan 15 '23
I did a bunch of research (reading papers, scraping data about user preferences, paresing articles and tutorials) to work out which was the best training method. TL:DR it's dreambooth because Dreambooth's popularity means it will be easier to use, but textual inversion seems close to as good with a much smaller output and LoRA is faster.
The findings can be found in this spreadsheet: https://docs.google.com/spreadsheets/d/1pIzTOy8WFEB1g8waJkA86g17E0OUmwajScHI3ytjs64/edit?usp=sharing
And I walk through my findings in this video: https://youtu.be/dVjMiJsuR5o
Hopefully this is helpful to someone.
61
u/FrostyAudience7738 Jan 15 '23
Hypernetworks aren't swapped in, they're attached at certain points into the model. The model you're using at runtime has a different shape when you use a hypernetwork. Hence why you get to pick a network shape when you create a new hypernetwork.
LORA in contrast changes the weights of the existing model by some delta, which is what you're training.
17
u/wowy-lied Jan 15 '23
Did not know about LoRA.
Only tried Hypernetworks as i only have a 8GB vram card and all other methods are running out of vram. It is interesting to see the flow of data here, help understanding it a little more, thanks you !
51
u/eugene20 Jan 15 '23 edited Jan 15 '23
Well researched apart from the part where it used SKS. Some training example used it, many copied that part of the example and later complained about getting guns in their images.
That didn't happen here but it's still best to stop perpetuating the use of SKS as your token, it's a rifle
2
u/Zipp425 Official CivitAi Jan 16 '23
Totally unrelated, but I love excalidraw and your username is great.
86
u/[deleted] Jan 15 '23 edited Jan 15 '23
Crazy how fast things are moving. In a year this will probably look so last century.
Soon we'll pop in to a photobooth, get a 360° scan and 5 minutes later we can print out a holiday snapshot from our vacation on Mars.
13
u/4lt3r3go Jan 15 '23
This video was actually the best thing on the topic i ever saw.
a must see
https://www.youtube.com/watch?v=dVjMiJsuR5o
6
u/OrnsteinSmoughGwyn Jan 15 '23
Oh my god. Whoever did this is a godsend. I’ve always been curious about how these technologies differ from each other, but I have no background in programming. Thank you.
4
u/Corridor_Digital Mar 10 '23
Wow, awesome work, OP ! Thank you.
I spent some time gathering data and comparing various approaches to fine-tuning SD. I want to make the most complete and accurate benchmark ever, in order to make it easy for anyone trying to customize a SD model to chose the appropriate method. I used data from your comparison.
I compare: DreamBooth, Hypernetworks, LoRa, Textual Inversion and naive fine-tuning.
For each method, you get information about:
Please tell me what you think, or comment on the Google Sheet if you want me to add any information (leave a name/nickname, I'll credit you in a Contributors section). This is and will always be public.
Link to the benchmark: Google Sheet
Thanks a lot !
1
u/chillaxinbball Jan 15 '23
Nice visualization. Where would aesthetic gradients fit? https://github.com/vicgalle/stable-diffusion-aesthetic-gradients
5
u/[deleted] Jan 15 '23
Yeah but still don't understand the difference in the result. What's the up- and downsides of TI, Lora and hypernetwork? Aparently they all just help to "find" the desired style or object in the noise but don't teach the model new styles or objects, right?
4
u/[deleted] Jan 15 '23
One tiny note, DreamBooth now allows you to do textual inversion, and inject that embedding directly into the text encoder before training.
2
u/victorkin11 Jan 15 '23
Are there any way to training img2img? like depth maps or normal maps output?
2
u/[deleted] Jan 15 '23
Cool visualizations!
2
u/TheComforterXL Jan 15 '23
Thank you for all your excellent work! I think your effort helps a lot of us to understand all this a little bit better.
1
u/OldFisherman8 Jan 15 '23
Ah, this is a really nice visual representation. By looking at it, I can understand why the hypernetworks are the most versatile and powerful tool to fine-tune SD and it has even more potential for fine-tuning details. This is fantastic. Thanks for posting this. By the way, may I ask what the source of the diagram is?
1
u/HappyPoe Jan 15 '23
Any idea what they used to do the drawings?
1
u/TheWebbster Jan 15 '23
Thanks for explaining this. I've been trying to find some succinct information on this for some time now and hadn't come across anything this easy to digest!
1
u/DaniyarQQQ Jan 15 '23
So in every types of training, we should use less popular text tokens like sks or ohwx? Even when we are trying to add new embedding?
1
u/CeFurkan Jan 15 '23
very well explanation.
1
u/JakcCSGO Jan 15 '23
Can somebody explain to me what class images exactly do and how they get treated in dreambooth?
1
u/lordpuddingcup Jan 15 '23
Why does hypernetworks not have any + or - associated?
1
u/JumpingQuickBrownFox Jan 15 '23
Great work!
1
u/Gab1159 Jan 15 '23
I've never really understood LORA, is it a sort of embedding or model you need to add? Can it train whole concepts or style like Dreambooth of TI?
Also, any reason why the entire community here kinda ignores it?
1
u/1OO_percent_legit Jan 15 '23
Lora is really good for anyone who is wondering about trying it, go for it
1
u/kidelaleron Stability Staff Jan 15 '23
LoRA nets also take up a relatively tiny space (80-200 megabytes)
1
u/Y0z64 Jan 15 '23
Extremely helpfull, good post
1
u/freshairproject Jan 16 '23
wow! this is extremely helpful! As an SD newbie (but with a RTX4090), I guess I should be using Dreambooth then? I've only been playing around with the built-in training inside Automatic1111, I guess thats the textual inversion method
1
u/IcookFriedEggs Jan 16 '23 edited Jan 16 '23
I tried dreambooth and textual inversion using 19 photos of my wife, all of them carefully chosen to have similar (not identical) face/head size. All photos was cropped via BIRME website at 512*512. They all have a text file with the same name to describe the content.
For dreambooth I used learning rate of 2e-5 (much higher than previous 2e-6) but I can get pretty good result at 1200-1500 iterations (1.13 it/sec)
For textual inversion I used the learning rate of (5e-03:200, 5e-04:500, 5e-05:800, 5e-06:1000, 5e-07), I couldn't get good result at 8000 iterations.
For people with face training experience, do I need to set the learning rate of textual inversion to be higher after first 1000 iter? Or it means dreambooth is better at training faces than textual inversion?
1
u/throwaway_WeirdLease Jan 17 '23
I think this might be the only explanation of Dreambooth on the internet outside of the original paper. Thank you.
1
u/brett_riverboat Jan 17 '23
So are there any techniques right now that expand the existing model? Or is that actually not possible because it's basically about altering biases?
1
u/Spare_Grapefruit7254 Jan 19 '23
It seems that for the four fine-tune ways, they all "froze" different parts of the larger network. DreamBooth only froze VAE, or VAE and CLIP, while others froze most parts of the networks. That can explain why DreamBooth has the most potential.
The visualization is great, thx for sharing.
1
u/thatisahugepileofshi Jan 21 '23
Nice cheat sheet. Did you make any other like this?
1
u/Designer-One4906 Feb 13 '23
It might sound like a dump question but how do you evaluate the results of finetuning with a matrix? Like something else than running a few prompts and watching whats happening?
1
u/MoneyNo373 Mar 06 '23
Does anyone know where the "how does stable diffusion work" infographic of the same art style can be found?
1
u/SalsaRice Jan 15 '23
Team textual inversion here.
They are just way, way, way, way too convenient. Every other type of file is several gb or at a minimum ~300mb, with TI embeddings being like 40kb. Lol it's just insane how small they are.
Also, TI embeddings are just easier to use. Don't need to go into the settings to constantly turn them on/off.
0
u/[deleted] Jan 15 '23
[deleted] — view deleted comment
0
u/[deleted] Jan 15 '23
[deleted] — view deleted comment
0
u/[deleted] Jan 15 '23
[deleted] — view deleted comment