sbusso / dagger-stable-diffusion-lora

A Stable Diffusion LoRA pipeline using Dagger.io: pipelines as (python) code

Home Page:https://dagger.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🌸 Fine-tuning Stable Diffusion using LoRA with Dagger

This example shows how to create brand assets for merchandise from some screenshots of a brand's website:

dagger-stable-diffusion-lora

It's implemented as a Stable Diffusion LoRA pipeline using Dagger: pipelines as (python) code.

  • Go to lambdalabs.com, or any other GPU provider of your choice (the instructions below were tested on Lambda)
  • Get an instance (e.g. A100 or A10). Min GPU memory is 16GB, tested on 24GB
  • Hit up Jupyter (or SSH in, but Jupyter makes viewing the outputs easier 😊)

πŸ‹ New terminal, add user to docker group

sudo adduser ubuntu docker
sudo su - ubuntu

🐍 Install newer Python

sudo add-apt-repository ppa:deadsnakes/ppa

Press enter to install the PPA.

sudo apt install -y socat python3.10-venv
python3.10 -m virtualenv venv
. venv/bin/activate
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

πŸš€ Install Dagger CLI

( cd /usr/local ; curl -L https://dl.dagger.io/dagger/install.sh | sudo sh )

βš™οΈ Check out repo and configure it

git clone https://github.com/lukemarsden/dagger-stable-diffusion-lora
cd dagger-stable-diffusion-lora
pip install -r requirements.txt
cp config.yml.sample config.yml

Now open dagger-stable-diffusion-lora/config.yml in the Jupyter editor and change anything you like.

πŸš‚ Train some LoRAs!

Back in the first terminal, run:

export _EXPERIMENTAL_DAGGER_INTERACTIVE_TUI=1
dagger run python lora.py

Now go and have lunch while you pull docker images & train some LoRAs 😊

...

If you're curious to watch the progress, in another terminal tab, do sudo docker ps and sudo docker logs -f <container_id> for some of the running jobs.

Welcome back, check out output/inference to see the results!

πŸƒ Observe the dagger cache making things faster

Now uncomment some of the prompts and/or brands in the config.yml and re-run, note how the Dagger cache saves you from having to redo any work that it's already done!

πŸ’Έ Remember to shut down your GPU

If you like keeping your money!

About

A Stable Diffusion LoRA pipeline using Dagger.io: pipelines as (python) code

https://dagger.io


Languages

Language:Python 92.7%Language:Dockerfile 7.3%