@@ -83,11 +83,13 @@ def test_pipeline_signature(self):
8383 )
8484
8585 def _get_dummy_image_embeds (self , cross_attention_dim : int = 32 ):
86- return torch .zeros ((2 , 1 , cross_attention_dim ), device = torch_device )
86+ return torch .randn ((2 , 1 , cross_attention_dim ), device = torch_device )
8787
8888 def _modify_inputs_for_ip_adapter_test (self , inputs : Dict [str , Any ]):
8989 inputs ["output_type" ] = "np"
9090 inputs ["return_dict" ] = False
91+ if "image" in inputs .keys ():
92+ inputs ["num_inference_steps" ] = 4
9193 return inputs
9294
9395 def test_ip_adapter (self , expected_max_diff : float = 1e-4 ):
@@ -114,7 +116,7 @@ def test_ip_adapter(self, expected_max_diff: float = 1e-4):
114116 # forward pass with single ip adapter, but with scale of adapter weights
115117 inputs = self ._modify_inputs_for_ip_adapter_test (self .get_dummy_inputs (torch_device ))
116118 inputs ["ip_adapter_image_embeds" ] = [self ._get_dummy_image_embeds (cross_attention_dim )]
117- pipe .set_ip_adapter_scale (1 .0 )
119+ pipe .set_ip_adapter_scale (42 .0 )
118120 output_with_adapter_scale = pipe (** inputs )[0 ]
119121
120122 pipe .unet ._load_ip_adapter_weights ([adapter_state_dict_1 , adapter_state_dict_2 ])
@@ -128,7 +130,7 @@ def test_ip_adapter(self, expected_max_diff: float = 1e-4):
128130 # forward pass with multi ip adapter, but with scale of adapter weights
129131 inputs = self ._modify_inputs_for_ip_adapter_test (self .get_dummy_inputs (torch_device ))
130132 inputs ["ip_adapter_image_embeds" ] = [self ._get_dummy_image_embeds (cross_attention_dim )] * 2
131- pipe .set_ip_adapter_scale ([0.5 , 0.5 ])
133+ pipe .set_ip_adapter_scale ([42.0 , 42.0 ])
132134 output_with_multi_adapter_scale = pipe (** inputs )[0 ]
133135
134136 max_diff_without_adapter_scale = np .abs (output_without_adapter_scale - output_without_adapter ).max ()
0 commit comments