@@ -135,9 +135,9 @@ def test_compare_to_diffusers_pipeline(self, model_arch: str):
135
135
ov_output = ov_pipeline (** inputs , generator = get_generator ("pt" , SEED )).images
136
136
diffusers_output = diffusers_pipeline (** inputs , generator = get_generator ("pt" , SEED )).images
137
137
138
- np .testing .assert_allclose (ov_output , diffusers_output , atol = 1e-4 , rtol = 1e-2 )
138
+ np .testing .assert_allclose (ov_output , diffusers_output , atol = 6e-3 , rtol = 1e-2 )
139
139
140
- @parameterized .expand (SUPPORTED_ARCHITECTURES )
140
+ @parameterized .expand ([ "stable-diffusion" , "stable-diffusion-xl" , "latent-consistency" ] )
141
141
@require_diffusers
142
142
def test_callback (self , model_arch : str ):
143
143
height , width , batch_size = 64 , 128 , 1
@@ -184,9 +184,10 @@ def test_shape(self, model_arch: str):
184
184
elif output_type == "pt" :
185
185
self .assertEqual (outputs .shape , (batch_size , 3 , height , width ))
186
186
else :
187
+ out_channels = pipeline .unet .config .out_channels if pipeline .unet is not None else pipeline .transformer .config .out_channels
187
188
self .assertEqual (
188
189
outputs .shape ,
189
- (batch_size , 4 , height // pipeline .vae_scale_factor , width // pipeline .vae_scale_factor ),
190
+ (batch_size , out_channels , height // pipeline .vae_scale_factor , width // pipeline .vae_scale_factor ),
190
191
)
191
192
192
193
@parameterized .expand (SUPPORTED_ARCHITECTURES )
@@ -229,6 +230,22 @@ def test_negative_prompt(self, model_arch: str):
229
230
do_classifier_free_guidance = True ,
230
231
negative_prompt = negative_prompt ,
231
232
)
233
+ elif model_arch == "stable-diffusion-3" :
234
+ (
235
+ inputs ["prompt_embeds" ],
236
+ inputs ["negative_prompt_embeds" ],
237
+ inputs ["pooled_prompt_embeds" ],
238
+ inputs ["negative_pooled_prompt_embeds" ],
239
+ ) = pipeline .encode_prompt (
240
+ prompt = prompt ,
241
+ prompt_2 = None ,
242
+ prompt_3 = None ,
243
+ num_images_per_prompt = 1 ,
244
+ device = torch .device ("cpu" ),
245
+ do_classifier_free_guidance = True ,
246
+ negative_prompt = negative_prompt ,
247
+ )
248
+
232
249
else :
233
250
inputs ["prompt_embeds" ], inputs ["negative_prompt_embeds" ] = pipeline .encode_prompt (
234
251
prompt = prompt ,
@@ -288,11 +305,12 @@ def test_height_width_properties(self, model_arch: str):
288
305
)
289
306
290
307
self .assertFalse (ov_pipeline .is_dynamic )
308
+ expected_batch = batch_size * num_images_per_prompt
309
+ if ov_pipeline .unet is not None and "timestep_cond" not in {inputs .get_any_name () for inputs in ov_pipeline .unet .model .inputs }:
310
+ expected_batch *= 2
291
311
self .assertEqual (
292
312
ov_pipeline .batch_size ,
293
- batch_size
294
- * num_images_per_prompt
295
- * (2 if "timestep_cond" not in {inputs .get_any_name () for inputs in ov_pipeline .unet .model .inputs } else 1 ),
313
+ expected_batch ,
296
314
)
297
315
self .assertEqual (ov_pipeline .height , height )
298
316
self .assertEqual (ov_pipeline .width , width )
@@ -369,7 +387,7 @@ def test_num_images_per_prompt(self, model_arch: str):
369
387
outputs = pipeline (** inputs , num_images_per_prompt = num_images_per_prompt ).images
370
388
self .assertEqual (outputs .shape , (batch_size * num_images_per_prompt , height , width , 3 ))
371
389
372
- @parameterized .expand (SUPPORTED_ARCHITECTURES )
390
+ @parameterized .expand ([ "stable-diffusion" , "stable-diffusion-xl" , "latent-consistency" ] )
373
391
@require_diffusers
374
392
def test_callback (self , model_arch : str ):
375
393
height , width , batch_size = 32 , 64 , 1
@@ -416,9 +434,10 @@ def test_shape(self, model_arch: str):
416
434
elif output_type == "pt" :
417
435
self .assertEqual (outputs .shape , (batch_size , 3 , height , width ))
418
436
else :
437
+ out_channels = pipeline .unet .config .out_channels if pipeline .unet is not None else pipeline .transformer .config .out_channels
419
438
self .assertEqual (
420
439
outputs .shape ,
421
- (batch_size , 4 , height // pipeline .vae_scale_factor , width // pipeline .vae_scale_factor ),
440
+ (batch_size , out_channels , height // pipeline .vae_scale_factor , width // pipeline .vae_scale_factor ),
422
441
)
423
442
424
443
@parameterized .expand (SUPPORTED_ARCHITECTURES )
@@ -500,11 +519,12 @@ def test_height_width_properties(self, model_arch: str):
500
519
)
501
520
502
521
self .assertFalse (ov_pipeline .is_dynamic )
522
+ expected_batch = batch_size * num_images_per_prompt
523
+ if ov_pipeline .unet is not None and "timestep_cond" not in {inputs .get_any_name () for inputs in ov_pipeline .unet .model .inputs }:
524
+ expected_batch *= 2
503
525
self .assertEqual (
504
526
ov_pipeline .batch_size ,
505
- batch_size
506
- * num_images_per_prompt
507
- * (2 if "timestep_cond" not in {inputs .get_any_name () for inputs in ov_pipeline .unet .model .inputs } else 1 ),
527
+ expected_batch
508
528
)
509
529
self .assertEqual (ov_pipeline .height , height )
510
530
self .assertEqual (ov_pipeline .width , width )
@@ -586,7 +606,7 @@ def test_num_images_per_prompt(self, model_arch: str):
586
606
outputs = pipeline (** inputs , num_images_per_prompt = num_images_per_prompt ).images
587
607
self .assertEqual (outputs .shape , (batch_size * num_images_per_prompt , height , width , 3 ))
588
608
589
- @parameterized .expand (SUPPORTED_ARCHITECTURES )
609
+ @parameterized .expand ([ "stable-diffusion" , "stable-diffusion-xl" ] )
590
610
@require_diffusers
591
611
def test_callback (self , model_arch : str ):
592
612
height , width , batch_size = 32 , 64 , 1
@@ -633,9 +653,10 @@ def test_shape(self, model_arch: str):
633
653
elif output_type == "pt" :
634
654
self .assertEqual (outputs .shape , (batch_size , 3 , height , width ))
635
655
else :
656
+ out_channels = pipeline .unet .config .out_channels if pipeline .unet is not None else pipeline .transformer .config .out_channels
636
657
self .assertEqual (
637
658
outputs .shape ,
638
- (batch_size , 4 , height // pipeline .vae_scale_factor , width // pipeline .vae_scale_factor ),
659
+ (batch_size , out_channels , height // pipeline .vae_scale_factor , width // pipeline .vae_scale_factor ),
639
660
)
640
661
641
662
@parameterized .expand (SUPPORTED_ARCHITECTURES )
@@ -717,11 +738,12 @@ def test_height_width_properties(self, model_arch: str):
717
738
)
718
739
719
740
self .assertFalse (ov_pipeline .is_dynamic )
741
+ expected_batch = batch_size * num_images_per_prompt
742
+ if ov_pipeline .unet is not None and "timestep_cond" not in {inputs .get_any_name () for inputs in ov_pipeline .unet .model .inputs }:
743
+ expected_batch *= 2
720
744
self .assertEqual (
721
745
ov_pipeline .batch_size ,
722
- batch_size
723
- * num_images_per_prompt
724
- * (2 if "timestep_cond" not in {inputs .get_any_name () for inputs in ov_pipeline .unet .model .inputs } else 1 ),
746
+ expected_batch ,
725
747
)
726
748
self .assertEqual (ov_pipeline .height , height )
727
749
self .assertEqual (ov_pipeline .width , width )
0 commit comments