Skip to content

[train_custom_diffusion.py] Fix the LR schedulers when num_train_epochs is passed in a distributed training env#9308

Merged
sayakpaul merged 4 commits intohuggingface:mainfrom
AnandK27:AnandK27-custom-diffusion-LR-fix
Aug 29, 2024
Merged

[train_custom_diffusion.py] Fix the LR schedulers when num_train_epochs is passed in a distributed training env#9308
sayakpaul merged 4 commits intohuggingface:mainfrom
AnandK27:AnandK27-custom-diffusion-LR-fix

Conversation

@AnandK27
Copy link
Copy Markdown
Contributor

@AnandK27 AnandK27 commented Aug 29, 2024

What does this PR do?

Part of #8384

Test Script

export MODEL_NAME="CompVis/stable-diffusion-v1-4"
export OUTPUT_DIR="cat_model"
export INSTANCE_DIR="./data/cat"

accelerate launch train_custom_diffusion.py \
  --pretrained_model_name_or_path=$MODEL_NAME  \
  --instance_data_dir=$INSTANCE_DIR \
  --output_dir=$OUTPUT_DIR \
  --class_data_dir=./real_reg/cat/ \
  --with_prior_preservation --prior_loss_weight=1.0 \
  --class_prompt="cat" --num_class_images=20 \
  --instance_prompt="photo of a <new1> cat"  \
  --resolution=512  \
  --train_batch_size=2  \
  --learning_rate=1e-5  \
  --lr_warmup_steps=0 \
  --num_train_epochs=5 \
  --enable_xformers_memory_efficient_attention \
  --scale_lr --hflip  \
  --modifier_token "<new1>" \
  --validation_prompt="<new1> cat sitting in a bucket" \
  --report_to="wandb"

Fixes # (issue)
Fixed the num_train_epoch for train_custom_diffusion.py and a small fix to saving the text token during safe serialization.

Before submitting

Who can review?

@sayakpaul and @geniuspatrick
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

Copy link
Copy Markdown
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks clean. Thank you!

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@AnandK27
Copy link
Copy Markdown
Contributor Author

Hey @sayakpaul,
Fixed the formatting issue, the tests should pass now!

@AnandK27
Copy link
Copy Markdown
Contributor Author

@sayakpaul, it can be merged ig

@sayakpaul sayakpaul merged commit 40c13fe into huggingface:main Aug 29, 2024
@sayakpaul
Copy link
Copy Markdown
Member

Thanks for your contributions!

sayakpaul pushed a commit that referenced this pull request Dec 23, 2024
…chs` is passed in a distributed training env (#9308)

* Update train_custom_diffusion.py to fix the LR schedulers for `num_train_epochs`

* Fix saving text embeddings during safe serialization

* Fixed formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants