GithubHelp home page GithubHelp logo

Comments (12)

InB4DevOps avatar InB4DevOps commented on July 22, 2024 4

@ShivamShrirao a wiki would be nice to have nonetheless. For all the other knowledge surrounding DreamBooth with SD..

from diffusers.

ThereforeGames avatar ThereforeGames commented on July 22, 2024 3

Here you go: https://www.reddit.com/r/StableDiffusion/comments/ydip3s/guide_dreambooth_training_with_shivamshriraos/

from diffusers.

mhnoni avatar mhnoni commented on July 22, 2024 3

Here you go: https://www.reddit.com/r/StableDiffusion/comments/ydip3s/guide_dreambooth_training_with_shivamshriraos/

oh wow, thank you so much!

from diffusers.

patrickgalbraith avatar patrickgalbraith commented on July 22, 2024 3

This is what I did to get it working.

environment.yml

name: dbshiv
channels:
  - conda-forge
  - pytorch
  - nvidia
  - defaults
dependencies:
  - python>=3.10
  - pip
  - pytorch==1.12.1
  - cudatoolkit=11.6.0
  - numpy
  - pip:
    - accelerate==0.12.0
    - torchvision==0.13.1
    - torchaudio==0.12.1
    - ftfy
    - tensorboard
    - modelcards
    - bitsandbytes
    - transformers>=4.21.0
    - pyre-extensions==0.0.23
    - -e git+https://github.com/ShivamShrirao/diffusers.git@main#egg=diffusers

train.bat

set HUGGINGFACE_TOKEN="PUT YOUR TOKEN HERE"
set INSTANCE_NAME="dboperson"
set CLASS_NAME="person"
 
set INSTANCE_DIR="./dataset/source_images/dboperson"
set OUTPUT_DIR="./output/dboperson"
set CLASS_DIR="./dataset/class_images/person"
 
set NUM_INSTANCE_IMAGES=10
set /a NUM_CLASS_IMAGES=%NUM_INSTANCE_IMAGES%*12
set /a MAX_NUM_STEPS = %NUM_INSTANCE_IMAGES%*80
set LR_SCHEDULE="polynomial"
set /a LR_WARMUP_STEPS=%MAX_NUM_STEPS%/10
 
set INSTANCE_PROMPT="%INSTANCE_NAME% %CLASS_NAME%"
 
call T:/programs/anaconda3/Scripts/activate.bat
call conda activate dbshiv
 
accelerate launch train_dreambooth.py ^
  --pretrained_model_name_or_path="runwayml/stable-diffusion-v1-5" ^
  --pretrained_vae_name_or_path="stabilityai/sd-vae-ft-mse" ^
  --tokenizer_name=%TOKENIZER_NAME% ^
  --instance_data_dir=%INSTANCE_DIR% ^
  --class_data_dir=%CLASS_DIR% ^
  --output_dir=%OUTPUT_DIR% ^
  --with_prior_preservation --prior_loss_weight=1.0 ^
  --instance_prompt=%INSTANCE_PROMPT% ^
  --class_prompt=%CLASS_NAME% ^
  --seed=1337 ^
  --resolution=512 ^
  --train_batch_size=1 ^
  --train_text_encoder ^
  --mixed_precision="fp16" ^
  --gradient_accumulation_steps=1 ^
  --learning_rate=1e-6 ^
  --lr_scheduler=%LR_SCHEDULE% ^
  --lr_warmup_steps=%LR_WARMUP_STEPS% ^
  --num_class_images=%NUM_CLASS_IMAGES% ^
  --sample_batch_size=4 ^
  --max_train_steps=%MAX_NUM_STEPS% ^
  --not_cache_latents ^
  --save_interval=250
pause

Setup notes

git clone https://github.com/ShivamShrirao/diffusers ShivamShriraoDiffusers
cd ShivamShriraoDiffusers/examples/dreambooth

# Note the pytorch version used is important since newer versions don't work right now
conda env create -f environment.yml
conda activate dbshiv

# Download https://github.com/C43H66N12O12S2/stable-diffusion-webui/releases/download/f/xformers-0.0.14.dev0-cp310-cp310-win_amd64.whl
pip install -U -I --no-deps xformers-0.0.14.dev0-cp310-cp310-win_amd64.whl

# Run accelerate config
#  In which compute environment are you running? ([0] This machine, [1] AWS (Amazon SageMaker)): 0
#  Which type of machine are you using? ([0] No distributed training, [1] multi-CPU, [2] multi-GPU, [3] TPU [4] MPS): 0
#  Do you want to run your training on CPU only (even if a GPU is available)? [yes/NO]:no
#  Do you want to use DeepSpeed? [yes/NO]: no
#  Do you wish to use FP16 or BF16 (mixed precision)? [NO/fp16/bf16]: FP16
accelerate config

# Make sure GPU is enabled in the follow output, if not then pytorch install is not correct
accelerate env

# To train update and run
train.bat

# To convert to checkpoint
python convert_diffusers_to_original_stable_diffusion.py --model_path="./output/out" --checkpoint_path="./output/checkpoint.ckpt"

from diffusers.

mhnoni avatar mhnoni commented on July 22, 2024 2

can't make it run on windows natively, getting this error after running python train_dreambooth.py
train_dreambooth.py: error: the following arguments are required: --pretrained_m odel_name_or_path, --pretrained_vae_name_or_path, --instance_data_dir
maybe I'm doing something wrong? the only difference I made is to run python train_dreambooth.py instead of launch.sh for Linux.

@mhnoni I would suggest watching the video on the below link and read carefully the updates on the video description. You can run it locally by following the steps carefully in that video.

(https://youtu.be/w6PTviOCYQY)

That one uses wsl to install Linux. I would like to use it natively on windows without Linux which seems possible but no guide on how to run the last command on windows, I mean instead of launch.sh we should have a python file to run train_dreambooth.py but not idea how to do that.

from diffusers.

InB4DevOps avatar InB4DevOps commented on July 22, 2024 1

@ShivamShrirao can we please have a Wiki in this repo where we could document things like this?

from diffusers.

ShivamShrirao avatar ShivamShrirao commented on July 22, 2024 1

@InB4DevOps yeah I wanted to but I haven't been able to verify them myself. Like the one linked here doesn't install xformers. Also the devs for xformers and bitsandbytes have been working on getting them officially working on windows.
Will add a section where I can add these unverified resources until then.

from diffusers.

NeoAnthropocene avatar NeoAnthropocene commented on July 22, 2024 1

@InB4DevOps >

Thank you so much. This will save so much time :)

from diffusers.

NeoAnthropocene avatar NeoAnthropocene commented on July 22, 2024

can't make it run on windows natively, getting this error after running python train_dreambooth.py

train_dreambooth.py: error: the following arguments are required: --pretrained_m odel_name_or_path, --pretrained_vae_name_or_path, --instance_data_dir

maybe I'm doing something wrong? the only difference I made is to run python train_dreambooth.py instead of launch.sh for Linux.

@mhnoni
I would suggest watching the video on the below link and read carefully the updates on the video description. You can run it locally by following the steps carefully in that video.

(https://youtu.be/w6PTviOCYQY)

from diffusers.

mhnoni avatar mhnoni commented on July 22, 2024

regarding xformers
from auto111 code:
pip install https://github.com/C43H66N12O12S2/stable-diffusion-webui/releases/download/c/xformers-0.0.14.dev0-cp310-cp310-win_amd64.whl

needs python 10.
I was able to install it, but I can't confirm if it will work or not since I only have 8GBVram. waiting for deepspeed.

from diffusers.

NeoAnthropocene avatar NeoAnthropocene commented on July 22, 2024

@patrickgalbraith , thanks for sharing this clean code.
I wonder why you are using the LR Scheduler with the "polynomial". Did you get better results compared with "constant" parameter?

I don't have deep knowledge about it but I'm trying to find out the best results by trying different parameters that I saw from other examples around the internet. I just wanted to know if it worth to spend time on it or not.

Thanks.

from diffusers.

InB4DevOps avatar InB4DevOps commented on July 22, 2024

@patrickgalbraith , thanks for sharing this clean code. I wonder why you are using the LR Scheduler with the "polynomial". Did you get better results compared with "constant" parameter?

I don't have deep knowledge about it but I'm trying to find out the best results by trying different parameters that I saw from other examples around the internet. I just wanted to know if it worth to spend time on it or not.

Thanks.

Hey,

I did a comparison of all learning rate schedulers.
Read about it here:
https://www.reddit.com/r/StableDiffusion/comments/yd56cy/dreambooth_i_compared_all_learning_rate/

TL;DR: use constant

from diffusers.

Related Issues (20)

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.