Skip to content

allow Attend-and-excite pipeline work with different image sizes #2476

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 1 commit into from
Mar 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ def __call__(
max_iter_to_alter: int = 25,
thresholds: dict = {0: 0.05, 10: 0.5, 20: 0.8},
scale_factor: int = 20,
attn_res: int = 16,
):
r"""
Function invoked when calling the pipeline for generation.
Expand Down Expand Up @@ -762,6 +763,8 @@ def __call__(
Dictionary defining the iterations and desired thresholds to apply iterative latent refinement in.
scale_factor (`int`, *optional*, default to 20):
Scale factor that controls the step size of each Attend and Excite update.
attn_res (`int`, *optional*, default to 16):
The resolution of most semantic attention map.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something that could be changed during inference or not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

technically yes but I don't think it's a common use case to change

Basically, you would want to apply attend-and-excite on the most semantic attention resolutions. The paper was based on SD 1.5, and it used 16x16. But if users want to use it on a different model, they might want to test it on different resolutions to find it out.


Examples:

Expand Down Expand Up @@ -834,7 +837,7 @@ def __call__(
# 6. Prepare extra step kwargs. TODO: Logic should ideally just be moved out of the pipeline
extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta)

self.attention_store = AttentionStore()
self.attention_store = AttentionStore(attn_res=attn_res)
self.register_attention_control()

# default config for step size from original repo
Expand Down