You are an experienced social media manager of Twitter. You need to write a thread about LoRA (Low-Rank Adaptation) for for fine-tuning Stable Diffusion models explaining in detail how they works and how it's possible to train one. Write in a clear and professional way. Tweets must be long, clear and explainatory.
You can use this to take the infos:
'''
LoRAs (Low-Rank Adaptations) are smaller files (anywhere from 1MB ~ 200MB) that you combine with an existing Stable Diffusion checkpoint models to introduce new concepts to your models, so that your model can generate these concepts.
These new concepts generally fall under 1 of 2 categories: subjects or styles.
Subjects can be anything from fictional characters to real-life people, facial expressions, poses, props, objects & environments.
Styles include visual aesthetics, art styles, and artist styles.
Quick Facts:
Fine-tuning AI models to perform specific tasks can be slow and difficult. LoRA was created as a faster and more efficient way of fine-tuning large language models. LoRA was developed by Microsoft Research in 2021 [Paper][Github].
It was later adapted to diffusion models for image generation.
LoRAs are the most popular way to create custom generations because the hardware requirements to train them is much lower than that of full models. Their small size makes them easy to share and download.
You can train your own LoRA with as little as 10 training images
You must train your LoRA on top of a foundational/base model:
Most realistic LoRAs today are trained on Stable Diffusion v1.5 (or models based on it)
Most anime/cartoon/stylized LoRAs today are trained on NAI Diffusion (or models based on it)
The next generation of LoRAs will be trained on SDXL
Quick Use:
AUTOMATIC1111 users can use LoRAs by downloading them, placing them in the folder stable-diffusion-webui/models/Lora and then adding the phrase lora:LORA-FILENAME:WEIGHT to your prompt, where LORA-FILENAME is the filename of the LoRA without the file extension, and WEIGHT (which takes a value from 0-1) is the strength of the LoRA
Sometimes LoRAs have trigger words that you must use in the prompt in addition to the keyphrase above
You can use as many LoRAs in the same prompt as you want
In this guide, we'll briefly cover what a LoRA is, how it compares to other fine-tuning techniques, showcase some popular LoRAs, show you how to run them, and finally, show you how to train one.
This is part 4 of the Stable Diffusion for Beginners series:
Stable Diffusion for Beginners
Part 1: Getting Started: Overview and Installation
Part 2: Stable Diffusion Prompts Guide
Part 3: Stable Diffusion Settings Guide
Part 3: Models
Part 4: LoRAs
Part 5: Embeddings/Textual Inversions
Part 6: Inpainting
Part 7: Animation
What are LoRAs?
A LoRA is a type of training method for fine-tuning Stable Diffusion models.
What is fine-tuning?
Let's say we want to train a image model to generate images of our own likeness.
Training a model from scratch will be extremely expensive and prohibitive to most people.
Instead of training a new model from scratch, we can re-use an existing one as the starting point. We can take a model like Stable Diffusion v1.5 and train it on a much smaller dataset (the images of us), creating a model that is simultaneously good at the broad task of generating realistic images and the narrow task of generating images of our likeness.
LoRA vs Dreambooth
Dreambooth is another fine-tuning technique that lets you train your model on a concept like a character or style. Practically speaking, Dreambooth and LoRA are meant to achieve the same thing.
The difference is that Dreambooth updates the entire model, but LoRA outputs a small file external to the model.
This means Dreambooth training will produce a full checkpoint model (this is one of main ways people create custom models), but LoRA files must be used in combination with an existing checkpoint model.
In terms of quality, a well trained LoRA is comparable to a Dreambooth model. LoRA has the advantage of a much faster training process, lower GPU requirements, and smaller outputs.
LoRA vs Hypernetwork
Hypernetworks work almost the exact same as LoRA. They're also smaller files that you use with checkpoint models to introduce new concepts to your generations.
The difference is a technical one: hypernetworks and LoRAs both change values as they pass through the attention layers of the model, however they do this differently.
You can think of them as "legacy LoRAs" because they have largely become obsolete.
If you have a hypernetwork that you use and enjoy however, there's no reason to stop using it.
LoRA vs Textual Inversion
LoRA and Dreambooth are meant to teach a model a new concept.
Textual Inversion/Embeddings on the other hand, uses things that the model already knows to create a desired output. They're more like prompt helpers than anything.
Let's use faces as an example. When we're using a textual inversion to generate a face, the model isn't generating a "new" face.
Instead, our textual inversion is just a shortcut for the specific nose / chin / mouth / eyes combination already in the model that resembles what we want.
You can see the limitation: if it's not in the model already, it can't be produced by a textual inversion.
Textual Inversions remain very popular because they are used in Negative Prompts (a usage commonly referred to as a "negative embedding"). People train textual inversions on undesirable things like bad hands and mutations. When we place these in our negative prompts, we can improve almost every prompt.
What can LoRAs do?
LoRAs are extremely versatile. Here are some concepts that the Stable Diffusion community has trained LoRAs on:
Quality improvements (eg. Detail Tweaker)
Styles/aesthetics (eg. Arcane style, Studio Ghibli style, Anime Lineart)
Characters or people (eg. Makima, Cute_girl_mix)
Clothing or objects (eg. Hanfu, Taiwanese Foo)
Settings (eg. School building)
The generations below use the same model, same prompt, and same seed. The only difference is the presence of the LoRA:
no LoRA
using Colorwater (style LoRA)
no LoRA
using Hanfu (clothing LoRA)
no LoRA
using Anime Lineart (style LoRA)
You can use LoRAs with any Stable Diffusion model, so long as the model and LoRA are both part of the same series:
LoRAs trained from SD v1.x will only work with models trained from SD v1.x
LoRAs trained from SD v2.x will only work with models trained from SD v2.x
LoRAs trained from SDXL will only work with models trained from SDXL
Generally, realistic LoRAs work better with realistic models, and anime LoRAs work better with anime models. However this distinction is not so clear, as most popular models today are merges of realistic and anime/stylized models.
Sometimes, creators will usually have notes about recommended models in their LoRA descriptions.
Where do you download LoRAs?
There are 2 places to find LoRAs:
Civitai.com: Most popular and recommended
HuggingFace.co: Less popular. The problem is HuggingFace puts LoRAs in the same category as checkpoint models, so there's no easy way to find them.
I won't go into detail on NSFW LoRAs, but there are plenty on Civitai, you just have to make an account to see them.
Popular LoRAs
General Purpose LoRAs
LoRAs can be used to enhance image quality or produce interesting variations of an image.
epinoiseoffset - increases contrast for better quality images. Recommended 🔥
Detail Tweaker - increase or decrease the level of detail. Recommended 🔥
CharTurnerBeta - creates character turnarounds for character design
Less details
No LoRA
More details
Detail Tweaker LoRA with Counterfeit model
Style/Aesthetic LoRAs
Produce a certain aesthetic or art style.
Colorwater - watercolor style
Anime lineart - lineart / colorbook style
Anime tarot card art style - intricate tarot card illustration style
Blindbox - 3D chibi style
Anime Magazine Cover - magazine cover style
BlindBox LoRA with DreamShaper
BlindBox LoRA with AbyssOrangeMix
Character/Person LoRAs
Create a fictional character or a real-life person.
Yae Miko - Genshin Impact
Makima - Chainsaw Man
Jinx - League of Legends
Makima LoRA with CetusMix
Jinx LoRA with ReV Animated
Costume LoRAs
【Costume】Straitjacket - adds straightjacket to characters
Oversized Sweater/hoodie
Urban Samurai - techwear & katanas
How to use LoRAs
With AUTOMATIC1111
Prerequisite: You have a working and updated AUTOMATIC1111. Here are platform specific instructions:
NVIDIA GPU instructions
AMD GPU instructions
Mac instructions
You must also have a checkpoint model downloaded and placed in the folder stable-diffusion-webui/models/Stable-diffusion. I'll use Anything V3 in this example.
Download the LoRA file (.pt or .safetensor) and place it in the folder stable-diffusion-webui/models/Lora. As an example, I’ll use Detail Tweaker, but you can use any LoRA you want.
Start your WebUI (click webui-user.bat).
Under the Generate button, click on the Show Extra Networks icon. It’s a small pink icon:
Click on the LoRA tab. It will show all the LoRAs in the folder stable-diffusion-webui/models/Lora (if you don't see anything, click the grey Refresh button).
Click on the LoRA you want, and the LoRA keyphrase will be added to your prompt. You can use as many LoRAs in the same prompt as you want.
You can also just write the LoRA keyphrase manually. It follows the format:
lora:LORA-FILENAME:WEIGHT
LORA-FILENAME is the filename of the LoRA model, without the file extension (eg. no .safetensor).
WEIGHT is how strong you want the LoRA to be. The range is 0-1; 0 is the same as deactivating the LoRA, 1 is maximum strength. With many LoRAs, a weight of 1 can be overpowering to the point of creating poor results, so experiment with lower values like 0.5 to 0.8.
(Detail Tweaker is a little special. It goes in 2 directions, and accepts anything between -1 and 1. -1 will remove details, and 1 will add details.)
Trigger words: Sometimes LoRAs will have trigger words. These are words that activate the concept.
(Our example Detail Tweaker, does not have any trigger words. On the other hand, with a LoRA like Anime Lineart, you would want to include "lineart" in your prompt. The creator will usually tell you these trigger words, if any, in the LoRA description.)
Example
Write the prompt:
(extremely detailed CG unity 8k wallpaper),(masterpiece), (best quality), (ultra-detailed), (best illustration),(best shadow),(an extremely delicate and beautiful), dynamic angle, floating, finely detail,Depth of field,1girl,solo,girl with beautiful detailed despair face and long fluttering hair and beautiful detailed eyes,((blood)) lora:add_detail:1
Copy
And the negative prompt:
mutated hands and fingers:1.5,lowres, bad anatomy, bad hands, fused fingers,text error, liquid digit,missing fingers, extra digits,malformed feet, fewer digits, cropped,fused feet,worst quality, low quality, standard quality, jpeg artifacts , signature, watermark, username, blurry,bad mouth,cracked mouth
Copy
Set the seed: 3944989649
And then click Generate. Here's what I get.
Make sure your settings are all the same if you are trying to follow along. I am using the Euler a sampler, 20 sampling steps, and a 7 CFG Scale.
How can you tell what the LoRA is actually doing?
Change lora:add_detail:1 to lora:add_detail:0 (deactivating the LoRA completely), and then regenerate.
Then change this phrase to lora:add_detail:-1 and regenerate (remember the negative direction removes detail).
Then we can compare the generations:
lora:add_detail:-1
lora:add_detail:0
lora:add_detail:1
Adding detail gives a boost in detail, lighting and textures. On the other hand, removing details creates a flat style illustration which is appealing in its own way.
Training LoRAs
Training LoRAs has been compared to baking a cake, and that's the best analogy I've seen so far.
You try to get the best ingredients (training images), use the righ