Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Flax training script for controlnet #2818

Merged
merged 12 commits into from
Mar 28, 2023
Merged

[WIP]Flax training script for controlnet #2818

merged 12 commits into from
Mar 28, 2023

Conversation

yiyixuxu
Copy link
Collaborator

@yiyixuxu yiyixuxu commented Mar 24, 2023

wandb test run here: https://wandb.ai/yiyixu/train_controlnet_flax/runs/jye8xcs9?workspace=user-yiyixu

wget https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_1.png
export MODEL_DIR="runwayml/stable-diffusion-v1-5"
export OUTPUT_DIR="control_out"

python3 train_controlnet_flax.py \
 --pretrained_model_name_or_path=$MODEL_DIR \
 --output_dir=$OUTPUT_DIR \
 --dataset_name=fusing/fill50k \
 --resolution=512 \
 --learning_rate=1e-5 \
 --validation_image "./conditioning_image_1.png"  \
 --validation_prompt "red circle with blue background" \
 --validation_steps=1000 \
 --train_batch_size=1 \
 --revision="flax"\
 --report_to="wandb"

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 24, 2023

The documentation is not available anymore as the PR was closed or merged.

@jingyangcarl
Copy link

Hi, awesome works!! I run the code and find the following @yiyixuxu, any chance you can share some ideas on this? #2822

@yiyixuxu yiyixuxu changed the title [WIF]Flax training script for controlnet [WIP]Flax training script for controlnet Mar 26, 2023
Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

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

Super nice! Feel free to merge :-)

@patrickvonplaten
Copy link
Contributor

BTW, could you also add this:

export MODEL_DIR="runwayml/stable-diffusion-v1-5"
export OUTPUT_DIR="control_out"

python3 train_controlnet_flax.py \
 --pretrained_model_name_or_path=$MODEL_DIR \
 --output_dir=$OUTPUT_DIR \
 --dataset_name=fusing/fill50k \
 --resolution=512 \
 --learning_rate=1e-5 \
 --validation_image "./conditioning_image_1.png"  \
 --validation_prompt "red circle with blue background" \
 --validation_steps=12500 \
 --train_batch_size=1 \
 --revision="flax"\
 --report_to="wandb"

to the README here: https://github.com/huggingface/diffusers/blob/d9cf213e9b8cc59be953e1da7df916346612aef3/examples/controlnet/README.md

yiyixuxu and others added 6 commits March 27, 2023 06:24
@yiyixuxu
Copy link
Collaborator Author

I've been running into this issue this afternoon #2851
but for the last 2 times, I was able to save the model to the hub (despite the error message) - I will leave that issue open for now in case we run into this issue in the future

see an example repo here with an automatically generated model card here (checkpoint with 4k steps)
https://huggingface.co/YiYiXu/fill-circle-controlnet

I will merge this in now so that more people can start to test it. Will open a separate PR to add intermediate checkpointing and make other improvements based on feedback.

@sayakpaul
Copy link
Member

Thanks, @yiyixuxu. Do you plan on integrating the streaming support as we were discussing in #2840?

@yiyixuxu
Copy link
Collaborator Author

Thanks @sayakpaul
I'm taking a look right now, but you're much more of an expert in this than me:) I think it's up to you and @patrickvonplaten

@yiyixuxu yiyixuxu merged commit d4f846f into main Mar 28, 2023
@yiyixuxu yiyixuxu deleted the train-controlnet-flax branch March 28, 2023 05:13
@sayakpaul
Copy link
Member

sayakpaul commented Mar 28, 2023

I'm taking a look right now, but you're much more of an expert in this than me:)

Actually, I don't believe the changes for enabling streaming will be long. I already mentioned a couple of pointers in #2840 (comment). Maybe you could try following the changes I made in here in your next PR? Happy to guide you if need be.

But happy to open a PR and have you test the changes. Would that make sense?

@yiyixuxu
Copy link
Collaborator Author

@sayakpaul yeah a PR please! happy to test it out :)

@sayakpaul
Copy link
Member

Perf! Will have it opened as soon as possible.

w4ffl35 pushed a commit to w4ffl35/diffusers that referenced this pull request Apr 14, 2023
* add train_controlnet_flax

---------

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* add train_controlnet_flax

---------

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
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.

5 participants