Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 7.3k
[tests] speed up animatediff tests#8846
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
9655048ba7d298e4db18aaf8dce32080a33d22403d26fd5e1e7e227efd3da48324151396c03ef4a4ae0a39a0f3b597a59e9360b7a51e0be870cfa00File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -11,6 +11,7 @@ | ||||||
| AutoencoderKL, | ||||||
| DDIMScheduler, | ||||||
| MotionAdapter, | ||||||
| StableDiffusionPipeline, | ||||||
| UNet2DConditionModel, | ||||||
| UNetMotionModel, | ||||||
| ) | ||||||
| @@ -46,16 +47,19 @@ class AnimateDiffVideoToVideoPipelineFastTests( | ||||||
| ) | ||||||
| def get_dummy_components(self): | ||||||
| cross_attention_dim = 8 | ||||||
| block_out_channels = (8, 8) | ||||||
| torch.manual_seed(0) | ||||||
| unet = UNet2DConditionModel( | ||||||
| block_out_channels=(32, 64), | ||||||
| block_out_channels=block_out_channels, | ||||||
| layers_per_block=2, | ||||||
| sample_size=32, | ||||||
| sample_size=8, | ||||||
| in_channels=4, | ||||||
| out_channels=4, | ||||||
| down_block_types=("CrossAttnDownBlock2D", "DownBlock2D"), | ||||||
| up_block_types=("CrossAttnUpBlock2D", "UpBlock2D"), | ||||||
| cross_attention_dim=32, | ||||||
| cross_attention_dim=cross_attention_dim, | ||||||
| norm_num_groups=2, | ||||||
| ) | ||||||
| scheduler = DDIMScheduler( | ||||||
| @@ -66,18 +70,19 @@ def get_dummy_components(self): | ||||||
| ) | ||||||
| torch.manual_seed(0) | ||||||
| vae = AutoencoderKL( | ||||||
| block_out_channels=[32, 64], | ||||||
| block_out_channels=block_out_channels, | ||||||
| in_channels=3, | ||||||
| out_channels=3, | ||||||
| down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"], | ||||||
| up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"], | ||||||
| latent_channels=4, | ||||||
| norm_num_groups=2, | ||||||
| ) | ||||||
| torch.manual_seed(0) | ||||||
| text_encoder_config = CLIPTextConfig( | ||||||
| bos_token_id=0, | ||||||
| eos_token_id=2, | ||||||
| hidden_size=32, | ||||||
| hidden_size=cross_attention_dim, | ||||||
| intermediate_size=37, | ||||||
| layer_norm_eps=1e-05, | ||||||
| num_attention_heads=4, | ||||||
| @@ -87,8 +92,9 @@ def get_dummy_components(self): | ||||||
| ) | ||||||
| text_encoder = CLIPTextModel(text_encoder_config) | ||||||
| tokenizer = CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip") | ||||||
| torch.manual_seed(0) | ||||||
| motion_adapter = MotionAdapter( | ||||||
| block_out_channels=(32, 64), | ||||||
| block_out_channels=block_out_channels, | ||||||
| motion_layers_per_block=2, | ||||||
| motion_norm_num_groups=2, | ||||||
| motion_num_attention_heads=4, | ||||||
| @@ -127,6 +133,36 @@ def get_dummy_inputs(self, device, seed=0): | ||||||
| } | ||||||
| return inputs | ||||||
| def test_from_pipe_consistent_config(self): | ||||||
| assert self.original_pipeline_class == StableDiffusionPipeline | ||||||
| ||||||
| ifself.original_pipeline_class==StableDiffusionPipeline: |
a-r-r-o-wJul 25, 2024 •
edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only made the model size smaller here, for AnimateDiff, no? It can definitely be applied across everything though to gain a good speed up. In fact, we can still make the model smaller with 1 layer per block instead of 2, smaller block out channels, smaller cross attn, etc. Will be some effort if we'd like to do it, but always good to have these tests running faster IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for now it will be pretty easy and safe to update the from pipe tester mixin here
| classPipelineFromPipeTesterMixin: |
a-r-r-o-wJul 25, 2024 •
edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't updating that cause most, if not all, tests inheriting from PipelineFromPipeTesterMixin to fail?
For example, in the test test_from_pipe_consistent_config we use hf-internal-testing/tiny-stable-diffusion-pipe which has larger model sizes than the one we're using here (hf-internal-testing/tinier-stable-diffusion-pipe).
In order to use the latter, we will have to update all model configurations in all tests as well as expected_slice values.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.