@@ -101,7 +101,7 @@ def _test_stable_diffusion_xl_euler(self, expected_image_shape, expected_slice,
101101
102102 assert (
103103 np .abs (image_slice .flatten () - expected_slice ).max () < expected_max_diff
104- ), f "Image Slice does not match expected slice"
104+ ), "Image Slice does not match expected slice"
105105
106106
107107class SDXLModularIPAdapterTests :
@@ -114,30 +114,20 @@ def test_pipeline_inputs_and_blocks(self):
114114 parameters = blocks .input_names
115115
116116 assert issubclass (self .pipeline_class , ModularIPAdapterMixin )
117- self .assertIn (
118- "ip_adapter_image" ,
119- parameters ,
120- "`ip_adapter_image` argument must be supported by the `__call__` method" ,
121- )
122- self .assertIn (
123- "ip_adapter" ,
124- blocks .sub_blocks ,
125- "pipeline must contain an IPAdapter block" ,
126- )
117+ assert (
118+ "ip_adapter_image" in parameters
119+ ), "`ip_adapter_image` argument must be supported by the `__call__` method"
120+ assert "ip_adapter" in blocks .sub_blocks , "pipeline must contain an IPAdapter block"
127121
128122 _ = blocks .sub_blocks .pop ("ip_adapter" )
129123 parameters = blocks .input_names
130124 intermediate_parameters = blocks .intermediate_input_names
131- self .assertNotIn (
132- "ip_adapter_image" ,
133- parameters ,
134- "`ip_adapter_image` argument must be removed from the `__call__` method" ,
135- )
136- self .assertNotIn (
137- "ip_adapter_image_embeds" ,
138- intermediate_parameters ,
139- "`ip_adapter_image_embeds` argument must be supported by the `__call__` method" ,
140- )
125+ assert (
126+ "ip_adapter_image" not in parameters
127+ ), "`ip_adapter_image` argument must be removed from the `__call__` method"
128+ assert (
129+ "ip_adapter_image_embeds" not in intermediate_parameters
130+ ), "`ip_adapter_image_embeds` argument must be supported by the `__call__` method"
141131
142132 def _get_dummy_image_embeds (self , cross_attention_dim : int = 32 ):
143133 return torch .randn ((1 , 1 , cross_attention_dim ), device = torch_device )
@@ -213,14 +203,10 @@ def test_ip_adapter(self, expected_max_diff: float = 1e-4, expected_pipe_slice=N
213203 max_diff_without_adapter_scale = np .abs (output_without_adapter_scale - output_without_adapter ).max ()
214204 max_diff_with_adapter_scale = np .abs (output_with_adapter_scale - output_without_adapter ).max ()
215205
216- self .assertLess (
217- max_diff_without_adapter_scale ,
218- expected_max_diff ,
219- "Output without ip-adapter must be same as normal inference" ,
220- )
221- self .assertGreater (
222- max_diff_with_adapter_scale , 1e-2 , "Output with ip-adapter must be different from normal inference"
223- )
206+ assert (
207+ max_diff_without_adapter_scale < expected_max_diff
208+ ), "Output without ip-adapter must be same as normal inference"
209+ assert max_diff_with_adapter_scale > 1e-2 , "Output with ip-adapter must be different from normal inference"
224210
225211 # 2. Multi IP-Adapter test cases
226212 adapter_state_dict_1 = create_ip_adapter_state_dict (pipe .unet )
@@ -249,16 +235,12 @@ def test_ip_adapter(self, expected_max_diff: float = 1e-4, expected_pipe_slice=N
249235 output_without_multi_adapter_scale - output_without_adapter
250236 ).max ()
251237 max_diff_with_multi_adapter_scale = np .abs (output_with_multi_adapter_scale - output_without_adapter ).max ()
252- self .assertLess (
253- max_diff_without_multi_adapter_scale ,
254- expected_max_diff ,
255- "Output without multi-ip-adapter must be same as normal inference" ,
256- )
257- self .assertGreater (
258- max_diff_with_multi_adapter_scale ,
259- 1e-2 ,
260- "Output with multi-ip-adapter scale must be different from normal inference" ,
261- )
238+ assert (
239+ max_diff_without_multi_adapter_scale < expected_max_diff
240+ ), "Output without multi-ip-adapter must be same as normal inference"
241+ assert (
242+ max_diff_with_multi_adapter_scale > 1e-2
243+ ), "Output with multi-ip-adapter scale must be different from normal inference"
262244
263245
264246class SDXLModularControlNetTests :
@@ -270,16 +252,10 @@ def test_pipeline_inputs(self):
270252 blocks = self .pipeline_blocks_class ()
271253 parameters = blocks .input_names
272254
273- self .assertIn (
274- "control_image" ,
275- parameters ,
276- "`control_image` argument must be supported by the `__call__` method" ,
277- )
278- self .assertIn (
279- "controlnet_conditioning_scale" ,
280- parameters ,
281- "`controlnet_conditioning_scale` argument must be supported by the `__call__` method" ,
282- )
255+ assert "control_image" in parameters , "`control_image` argument must be supported by the `__call__` method"
256+ assert (
257+ "controlnet_conditioning_scale" in parameters
258+ ), "`controlnet_conditioning_scale` argument must be supported by the `__call__` method"
283259
284260 def _modify_inputs_for_controlnet_test (self , inputs : Dict [str , Any ]):
285261 controlnet_embedder_scale_factor = 2
@@ -325,14 +301,10 @@ def test_controlnet(self, expected_max_diff: float = 1e-4, expected_pipe_slice=N
325301 max_diff_without_controlnet_scale = np .abs (output_without_controlnet_scale - output_without_controlnet ).max ()
326302 max_diff_with_controlnet_scale = np .abs (output_with_controlnet_scale - output_without_controlnet ).max ()
327303
328- self .assertLess (
329- max_diff_without_controlnet_scale ,
330- expected_max_diff ,
331- "Output without controlnet must be same as normal inference" ,
332- )
333- self .assertGreater (
334- max_diff_with_controlnet_scale , 1e-2 , "Output with controlnet must be different from normal inference"
335- )
304+ assert (
305+ max_diff_without_controlnet_scale < expected_max_diff
306+ ), "Output without controlnet must be same as normal inference"
307+ assert max_diff_with_controlnet_scale > 1e-2 , "Output with controlnet must be different from normal inference"
336308
337309 def test_controlnet_cfg (self ):
338310 pipe = self .get_pipeline ()
@@ -354,7 +326,7 @@ def test_controlnet_cfg(self):
354326
355327 assert out_cfg .shape == out_no_cfg .shape
356328 max_diff = np .abs (out_cfg - out_no_cfg ).max ()
357- self . assertGreater ( max_diff , 1e-2 )
329+ assert max_diff > 1e-2 , "Output with CFG must be different from normal inference"
358330
359331
360332class SDXLModularGuiderTests :
@@ -378,7 +350,7 @@ def test_guider_cfg(self):
378350
379351 assert out_cfg .shape == out_no_cfg .shape
380352 max_diff = np .abs (out_cfg - out_no_cfg ).max ()
381- self . assertGreater ( max_diff , 1e-2 )
353+ assert max_diff > 1e-2 , "Output with CFG must be different from normal inference"
382354
383355
384356class SDXLModularPipelineFastTests (
0 commit comments