GithubHelp home page GithubHelp logo

control-lora-v3's Introduction

ControlLoRA Version 3: A Lightweight Neural Network To Control Stable Diffusion Spatial Information Version 3

ControlLoRA Version 3 is a neural network structure extended from ControlNet to control diffusion models by adding extra conditions.

Inspired by ControlLoRA, control-lora-v2 and script train_controlnet.py from diffusers, control-lora-v3 does not add new features, but provides a PEFT implement of ControlLoRA.

News

  • Jun. 08, 2024. Norm layer is trainable.
  • May. 19, 2024. Add DoRA.

Data

To train ControlLoRA, you should have image-conditioning_image-text datasets. Of course you can hardly train on LAION-5B dataset in direct like Stable Diffusion. Here are some:

Model

Stable Diffusion v1-5 is the base model.

Stable Diffusion v1-4, Stable Diffusion v2-1 need to be vertified.

Stable Diffusion XL needs to be vertified, but probably does not work.

Train

You can train either ControlNet or ControlLoRA using script train_control_lora.py.

Train ControlNet

By observation, training 50000 steps with batch size of 4 is the balance between image quality, control ability and time.

accelerate launch train_control_lora.py \
 --pretrained_model_name_or_path="runwayml/stable-diffusion-v1-5" \
 --output_dir="controlnet-model" \
 --dataset_name="fusing/fill50k" \
 --resolution=512 \
 --learning_rate=1e-5 \
 --train_batch_size=4 \
 --max_train_steps=100000 \
 --tracker_project_name="controlnet" \
 --checkpointing_steps=5000 \
 --validation_steps=5000 \
 --report_to wandb

Train ControlLoRA

To train ControlLoRA, add --use_lora in start command to activate it.

accelerate launch train_control_lora.py \
 --pretrained_model_name_or_path="runwayml/stable-diffusion-v1-5" \
 --output_dir="control_lora-model" \
 --dataset_name="fusing/fill50k" \
 --resolution=512 \
 --learning_rate=1e-4 \
 --train_batch_size=4 \
 --max_train_steps=100000 \
 --tracker_project_name="control_lora" \
 --checkpointing_steps=5000 \
 --validation_steps=5000 \
 --report_to wandb \
 --use_lora \
 --lora_r=32

You can also train ControlLoRA / ControlNet with your own dataset.

accelerate launch train_control_lora.py \
 --pretrained_model_name_or_path="stable-diffusion-v1-5" \
 --output_dir="control_lora-model" \
 --conditioning_image_column="hint" \
 --image_column="jpg" \
 --caption_column="txt" \
 --resolution=512 \
 --learning_rate=1e-4 \
 --train_batch_size=4 \
 --num_train_epochs=3 \
 --max_train_steps=100000 \
 --tracker_project_name="control_lora" \
 --checkpointing_steps=5000 \
 --validation_steps=5000 \
 --report_to wandb \
 --use_lora \
 --lora_r=32 \
 --custom_dataset="fill50k"

Merge

If you want to train ControlNet, you have already got it. If you got a lora, merge it!

python merge_lora.py

Test

Original image:

house

Output:

house_grid

Citation

@software{lavinal7122024controllorav3,
    author = {lavinal712},
    month = {5},
    title = {{ControlLoRA Version 3: A Lightweight Neural Network To Control Stable Diffusion Spatial Information Version 3}},
    url = {https://github.com/lavinal712/control-lora-v3},
    version = {1.0.0},
    year = {2024}
}

control-lora-v3's People

Contributors

lavinal712 avatar

Stargazers

Youxin Xing avatar  avatar FishNotFish avatar

Watchers

 avatar

control-lora-v3's Issues

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.