@@ -82,6 +82,7 @@ def _test_stable_diffusion_compile(in_queue, out_queue, timeout):
82
82
83
83
assert image .shape == (1 , 512 , 512 , 3 )
84
84
expected_slice = np .array ([0.38019 , 0.28647 , 0.27321 , 0.40377 , 0.38290 , 0.35446 , 0.39218 , 0.38165 , 0.42239 ])
85
+
85
86
assert np .abs (image_slice - expected_slice ).max () < 5e-3
86
87
except Exception :
87
88
error = f"{ traceback .format_exc ()} "
@@ -103,14 +104,15 @@ class StableDiffusionPipelineFastTests(
103
104
def get_dummy_components (self ):
104
105
torch .manual_seed (0 )
105
106
unet = UNet2DConditionModel (
106
- block_out_channels = (32 , 64 ),
107
- layers_per_block = 2 ,
107
+ block_out_channels = (4 , 8 ),
108
+ layers_per_block = 1 ,
108
109
sample_size = 32 ,
109
110
in_channels = 4 ,
110
111
out_channels = 4 ,
111
112
down_block_types = ("DownBlock2D" , "CrossAttnDownBlock2D" ),
112
113
up_block_types = ("CrossAttnUpBlock2D" , "UpBlock2D" ),
113
114
cross_attention_dim = 32 ,
115
+ norm_num_groups = 2 ,
114
116
)
115
117
scheduler = DDIMScheduler (
116
118
beta_start = 0.00085 ,
@@ -121,22 +123,23 @@ def get_dummy_components(self):
121
123
)
122
124
torch .manual_seed (0 )
123
125
vae = AutoencoderKL (
124
- block_out_channels = [32 , 64 ],
126
+ block_out_channels = [4 , 8 ],
125
127
in_channels = 3 ,
126
128
out_channels = 3 ,
127
129
down_block_types = ["DownEncoderBlock2D" , "DownEncoderBlock2D" ],
128
130
up_block_types = ["UpDecoderBlock2D" , "UpDecoderBlock2D" ],
129
131
latent_channels = 4 ,
132
+ norm_num_groups = 2 ,
130
133
)
131
134
torch .manual_seed (0 )
132
135
text_encoder_config = CLIPTextConfig (
133
136
bos_token_id = 0 ,
134
137
eos_token_id = 2 ,
135
138
hidden_size = 32 ,
136
- intermediate_size = 37 ,
139
+ intermediate_size = 64 ,
137
140
layer_norm_eps = 1e-05 ,
138
- num_attention_heads = 4 ,
139
- num_hidden_layers = 5 ,
141
+ num_attention_heads = 8 ,
142
+ num_hidden_layers = 3 ,
140
143
pad_token_id = 1 ,
141
144
vocab_size = 1000 ,
142
145
)
@@ -183,7 +186,7 @@ def test_stable_diffusion_ddim(self):
183
186
image_slice = image [0 , - 3 :, - 3 :, - 1 ]
184
187
185
188
assert image .shape == (1 , 64 , 64 , 3 )
186
- expected_slice = np .array ([0.5756 , 0.6118 , 0.5005 , 0.5041 , 0.5471 , 0.4726 , 0.4976 , 0.4865 , 0.4864 ])
189
+ expected_slice = np .array ([0.3203 , 0.4555 , 0.4711 , 0.3505 , 0.3973 , 0.4650 , 0.5137 , 0.3392 , 0.4045 ])
187
190
188
191
assert np .abs (image_slice .flatten () - expected_slice ).max () < 1e-2
189
192
@@ -317,7 +320,7 @@ def test_stable_diffusion_ddim_factor_8(self):
317
320
image_slice = image [0 , - 3 :, - 3 :, - 1 ]
318
321
319
322
assert image .shape == (1 , 136 , 136 , 3 )
320
- expected_slice = np .array ([0.5524 , 0.5626 , 0.6069 , 0.4727 , 0.386 , 0.3995 , 0.4613 , 0.4328 , 0.4269 ])
323
+ expected_slice = np .array ([0.4346 , 0.5621 , 0.5016 , 0.3926 , 0.4533 , 0.4134 , 0.5625 , 0.5632 , 0.5265 ])
321
324
322
325
assert np .abs (image_slice .flatten () - expected_slice ).max () < 1e-2
323
326
@@ -335,7 +338,7 @@ def test_stable_diffusion_pndm(self):
335
338
image_slice = image [0 , - 3 :, - 3 :, - 1 ]
336
339
337
340
assert image .shape == (1 , 64 , 64 , 3 )
338
- expected_slice = np .array ([0.5122 , 0.5712 , 0.4825 , 0.5053 , 0.5646 , 0.4769 , 0.5179 , 0.4894 , 0.4994 ])
341
+ expected_slice = np .array ([0.3411 , 0.5032 , 0.4704 , 0.3135 , 0.4323 , 0.4740 , 0.5150 , 0.3498 , 0.4022 ])
339
342
340
343
assert np .abs (image_slice .flatten () - expected_slice ).max () < 1e-2
341
344
@@ -375,7 +378,7 @@ def test_stable_diffusion_k_lms(self):
375
378
image_slice = image [0 , - 3 :, - 3 :, - 1 ]
376
379
377
380
assert image .shape == (1 , 64 , 64 , 3 )
378
- expected_slice = np .array ([0.4873 , 0.5443 , 0.4845 , 0.5004 , 0.5549 , 0.4850 , 0.5191 , 0.4941 , 0.5065 ])
381
+ expected_slice = np .array ([0.3149 , 0.5246 , 0.4796 , 0.3218 , 0.4469 , 0.4729 , 0.5151 , 0.3597 , 0.3954 ])
379
382
380
383
assert np .abs (image_slice .flatten () - expected_slice ).max () < 1e-2
381
384
@@ -394,7 +397,7 @@ def test_stable_diffusion_k_euler_ancestral(self):
394
397
image_slice = image [0 , - 3 :, - 3 :, - 1 ]
395
398
396
399
assert image .shape == (1 , 64 , 64 , 3 )
397
- expected_slice = np .array ([0.4872 , 0.5444 , 0.4846 , 0.5003 , 0.5549 , 0.4850 , 0.5189 , 0.4941 , 0.5067 ])
400
+ expected_slice = np .array ([0.3151 , 0.5243 , 0.4794 , 0.3217 , 0.4468 , 0.4728 , 0.5152 , 0.3598 , 0.3954 ])
398
401
399
402
assert np .abs (image_slice .flatten () - expected_slice ).max () < 1e-2
400
403
@@ -413,7 +416,7 @@ def test_stable_diffusion_k_euler(self):
413
416
image_slice = image [0 , - 3 :, - 3 :, - 1 ]
414
417
415
418
assert image .shape == (1 , 64 , 64 , 3 )
416
- expected_slice = np .array ([0.4873 , 0.5443 , 0.4845 , 0.5004 , 0.5549 , 0.4850 , 0.5191 , 0.4941 , 0.5065 ])
419
+ expected_slice = np .array ([0.3149 , 0.5246 , 0.4796 , 0.3218 , 0.4469 , 0.4729 , 0.5151 , 0.3597 , 0.3954 ])
417
420
418
421
assert np .abs (image_slice .flatten () - expected_slice ).max () < 1e-2
419
422
@@ -485,7 +488,7 @@ def test_stable_diffusion_negative_prompt(self):
485
488
image_slice = image [0 , - 3 :, - 3 :, - 1 ]
486
489
487
490
assert image .shape == (1 , 64 , 64 , 3 )
488
- expected_slice = np .array ([0.5114 , 0.5706 , 0.4772 , 0.5028 , 0.5637 , 0.4732 , 0.5169 , 0.4881 , 0.4977 ])
491
+ expected_slice = np .array ([0.3458 , 0.5120 , 0.4800 , 0.3116 , 0.4348 , 0.4802 , 0.5237 , 0.3467 , 0.3991 ])
489
492
490
493
assert np .abs (image_slice .flatten () - expected_slice ).max () < 1e-2
491
494
@@ -638,7 +641,7 @@ def test_stable_diffusion_1_1_pndm(self):
638
641
image_slice = image [0 , - 3 :, - 3 :, - 1 ].flatten ()
639
642
640
643
assert image .shape == (1 , 512 , 512 , 3 )
641
- expected_slice = np .array ([0.43625 , 0.43554 , 0.36670 , 0.40660 , 0.39703 , 0.38658 , 0.43936 , 0.43557 , 0.40592 ])
644
+ expected_slice = np .array ([0.3149 , 0.5246 , 0.4796 , 0.3218 , 0.4469 , 0.4729 , 0.5151 , 0.3597 , 0.3954 ])
642
645
assert np .abs (image_slice - expected_slice ).max () < 3e-3
643
646
644
647
def test_stable_diffusion_v1_4_with_freeu (self ):
@@ -665,7 +668,7 @@ def test_stable_diffusion_1_4_pndm(self):
665
668
image_slice = image [0 , - 3 :, - 3 :, - 1 ].flatten ()
666
669
667
670
assert image .shape == (1 , 512 , 512 , 3 )
668
- expected_slice = np .array ([0.57400 , 0.47841 , 0.31625 , 0.63583 , 0.58306 , 0.55056 , 0.50825 , 0.56306 , 0.55748 ])
671
+ expected_slice = np .array ([0.3458 , 0.5120 , 0.4800 , 0.3116 , 0.4348 , 0.4802 , 0.5237 , 0.3467 , 0.3991 ])
669
672
assert np .abs (image_slice - expected_slice ).max () < 3e-3
670
673
671
674
def test_stable_diffusion_ddim (self ):
0 commit comments