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

Add rescaled classifier free guidance and offset noise #72

Merged
merged 4 commits into from
Oct 24, 2023

Conversation

coryMosaicML
Copy link
Collaborator

This PR adds two simple tricks that are claimed to improve image quality.

Trick 1: Rescaled classifier free guidance (see sec. 3.4 here)

  • A simple rescaling of the latents during classifier free guidance to help ameliorate the image over exposure problem.

Trick 2: Offset noise (see here)

  • A trick for using to fine tune models such that they can generate lighter/darker images. Adds a slight offset to the noise during training.

Copy link
Contributor

@jazcollins jazcollins left a comment

Choose a reason for hiding this comment

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

Looks good to me!

If you wanted to make things even more concise, I left one suggestion to consolidate the boolean and float parameters for rescale guidance into a single Optional[float] parameter. The same could be done for the offset noise parameters - but what you wrote looks great and it is not necessary!

diffusion/models/stable_diffusion.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Landanjs Landanjs left a comment

Choose a reason for hiding this comment

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

LGTM. +1 to Jasmine's suggestion

@coryMosaicML coryMosaicML merged commit 1914a47 into mosaicml:main Oct 24, 2023
7 checks passed
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