Git Product home page Git Product logo

sd-ia3's Introduction

(IA)^3 for Stable Diffusion

Parameter-efficient fine-tuning of Stable Diffusion using (IA)^3.

YouTube Video Explanation

YouTube Video Explanation

Example

Before Fine-Tuning After Fine-Tuning
Donald Trump Donald Trump

The prompt is "donald trump", and the model is fine-tuned on pokemon-blip-captions for 25 epochs.

Description

Based on these papers:

Implemented in diffusers using an attention processor in attention.py.

Comparison to full fine-tuning

(IA)^3 has trade-offs similar to LoRA when comparing to full fine-tuning.

One major difference to LoRA is that (IA)^3 uses much less parameters. In general, it will most likely be faster and smaller, but less expressive.

  • Faster training
  • Smaller file size (~222 KB for Stable Diffusion 1.5 when learn_biases=False, about twice as much otherwise)
  • Can be swapped in and out of the base model during inference
  • Can be loaded into fine-tuned models that have the same architecture
  • Can be merged with the weights of the base model
    • Only possible when learn_biases=False without changing the architecture
    • Not currently implemented in this repo

Installation

First create an environment and install PyTorch.

Then install the pip dependencies:

pip install -r requirements.txt

Currently, bitsandbytes only supports Linux, so fine-tuning on Windows requires more VRAM.

Training

Training script in train.py. Based on this example script for diffusers.

Currently you can change the parameters by editing the variables at the top of the file and running the script:

python train.py

Inference

Inference script in infer.py to load the changes and generate images.

Currently you can change the parameters by editing the variables at the top of the file and running the script:

python infer.py

sd-ia3's People

Contributors

tripplyons avatar

Stargazers

 avatar  avatar Jean-Frédéric Faust avatar Martin Chtilianov avatar fabfish avatar eunzee avatar fishlegs avatar  avatar  avatar Rish avatar yule-li avatar  avatar  avatar Wang Yabin avatar Peter Baylies avatar Tim Kersey avatar 青龍聖者@bdsqlsz avatar Marcus Diemand avatar wolfi3 avatar Plams Li avatar  avatar  avatar MyGen avatar alleniver avatar  avatar Biorn Christiansen avatar  avatar Evgeny avatar René avatar Legion avatar Ömer Karışman avatar giorgio3000 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

alaqian

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.