GithubHelp home page GithubHelp logo

georgefwt / train-kohya-style-lora-in-diffusers Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 16 KB

kohya style lora training script in diffusers

Python 98.86% Shell 1.14%
diffusers kohya-sd-script kohya-webui lora

train-kohya-style-lora-in-diffusers's Introduction

Train Kohya-ss style LoRA in Diffusers

Difference between Kohya-ss LoRA and current Diffusers LoRA (9/29/2023)

Compared to Kohya-ss LoRA, Diffusers' LoRA is missing the LoRA on the ffn of the BasicTransformerBlock in unet, as well as the LoRA on the convolution layer of proj_in. As for the textencoder, the LoRA in the mlp is missing in Diffusers' version. This training script completes these missing LoRAs, making it identical to Kohya-ss LoRA.

Requirements

Diffusers version greater than 0.21.2. Because they implemented the Koyha-style LoRA loading, I reused most of their code for my implementation.

Training script example

I only implement Dreambooth trainig script here. You can run following command to start training:

export MODEL_NAME="runwayml/stable-diffusion-v1-5"
export INSTANCE_DIR="<your image folder>"
export OUTPUT_DIR="output/<output folder>"

accelerate launch train_dreambooth_lora.py \
  --pretrained_model_name_or_path=$MODEL_NAME  \
  --instance_data_dir=$INSTANCE_DIR \
  --output_dir=$OUTPUT_DIR \
  --instance_prompt="a photo of sks dog" \
  --resolution=512 \
  --train_batch_size=1 \
  --gradient_accumulation_steps=1 \
  --checkpointing_steps=100 \
  --learning_rate=1e-4 \
  --lr_scheduler="constant" \
  --lr_warmup_steps=0 \
  --max_train_steps=5000 \
  --validation_prompt="A close potrait of sks dog" \
  --validation_epochs=50 \
  --train_text_encoder \
  --seed="0" \

Inference script example

python inference_text_to_image_lora.py

train-kohya-style-lora-in-diffusers's People

Contributors

georgefwt avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.