Lesson 5 of 6 · 2 min
Real prompts with LoRA
A LoRA trains small extra weights on a frozen pretrained model. Use the maintained script in diffusers rather than writing your own loop.
pip install diffusers accelerate transformers peft datasets git clone https://github.com/huggingface/diffusers cd diffusers/examples/text_to_image && pip install -r requirements.txt accelerate launch train_text_to_image_lora.py \ --pretrained_model_name_or_path="stable-diffusion-v1-5/stable-diffusion-v1-5" \ --train_data_dir="../../../my_pictures" --resolution=512 \ --train_batch_size=1 --max_train_steps=1500 --learning_rate=1e-4 \ --output_dir="../../../my_lora"
Check the licence of the base model and of every picture. Do not train on a person's face without their consent.
