Skip to content

update flax controlnet training script #2951

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

Merged
merged 5 commits into from
Apr 5, 2023
Merged

update flax controlnet training script #2951

merged 5 commits into from
Apr 5, 2023

Conversation

yiyixuxu
Copy link
Collaborator

@yiyixuxu yiyixuxu commented Apr 3, 2023

This PR makes a few modifications to the flax controlnet training script in order to run with larger dataset:

  • allow load dataset with load_from_disk
  • add intermediate checkpointing
  • add a workaround for ValueError: Decompressed Data Too Large error that I got from torch dataloader
  • add CenterCrop to image transformation so that batching will work for images with different sizes and different width/ height

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 3, 2023

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

Comment on lines +53 to +54
LARGE_ENOUGH_NUMBER = 100
PngImagePlugin.MAX_TEXT_CHUNK = LARGE_ENOUGH_NUMBER * (1024**2)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment for the users to know why this needs to be set?

Copy link
Contributor

Choose a reason for hiding this comment

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

What exactly does this change do here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added a comment there - to prevent an error I would get when working with coyo700m "Decompressed Data Too Large"

Comment on lines 362 to 366
parser.add_argument(
"--load_from_disk",
action="store_true",
help="If True, will load a dataset that was previously saved using [`save_to_disk`] from `--train_data_dir`",
)
Copy link
Member

Choose a reason for hiding this comment

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

Provide a link to the load_from_disk documentation?

Copy link
Member

Choose a reason for hiding this comment

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

Also, the help seems a bit unclear to me. How does the dataset need to be saved?

nit: I think we can just do save_to_disk instead of [save_to_disk].

Comment on lines +1025 to +1028
controlnet.save_pretrained(
f"{args.output_dir}/{global_step}",
params=get_params_to_save(state.params),
)
Copy link
Member

Choose a reason for hiding this comment

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

Very cool!

Copy link
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.

Thanks for the changes!

My comments are mostly nits but this should be 99% ready to merge.

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.

OK for me!

@yiyixuxu yiyixuxu merged commit ee20d1f into main Apr 5, 2023
@yiyixuxu yiyixuxu deleted the canny-train branch April 5, 2023 01:49
w4ffl35 pushed a commit to w4ffl35/diffusers that referenced this pull request Apr 14, 2023
* load_from_disk + checkpointing_steps

* apply feedback
dg845 pushed a commit to dg845/diffusers that referenced this pull request May 6, 2023
* load_from_disk + checkpointing_steps

* apply feedback
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* load_from_disk + checkpointing_steps

* apply feedback
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.

4 participants