@@ -107,6 +107,28 @@ def test_tiled_autoencoder_rectangular_image(autoencoder: LatentDiffusionAutoenc
107
107
ensure_similar_images (sample_image , result , min_psnr = 37 , min_ssim = 0.985 )
108
108
109
109
110
+ @no_grad ()
111
+ @pytest .mark .parametrize ("img_width" , [960 , 968 , 976 , 1016 , 1024 , 1032 ])
112
+ def test_tiled_autoencoder_pathologic_sizes (
113
+ refiners_sd15_autoencoder : SD1Autoencoder ,
114
+ sample_image : Image .Image ,
115
+ test_device : torch .device ,
116
+ img_width : int ,
117
+ ):
118
+ # 968 is the pathologic case, just larger than (tile size - overlap): (128 - 8 + 1) * 8 = 968
119
+
120
+ autoencoder = refiners_sd15_autoencoder .to (device = test_device , dtype = torch .float32 )
121
+
122
+ sample_image = sample_image .crop ((0 , 0 , img_width // 4 , 400 ))
123
+ sample_image = sample_image .resize ((sample_image .width * 4 , sample_image .height * 4 ))
124
+
125
+ with autoencoder .tiled_inference (sample_image , tile_size = (1024 , 1024 )):
126
+ encoded = autoencoder .tiled_image_to_latents (sample_image )
127
+ result = autoencoder .tiled_latents_to_image (encoded )
128
+
129
+ ensure_similar_images (sample_image , result , min_psnr = 37 , min_ssim = 0.985 )
130
+
131
+
110
132
def test_value_error_tile_encode_no_context (autoencoder : LatentDiffusionAutoencoder , sample_image : Image .Image ) -> None :
111
133
with pytest .raises (ValueError ):
112
134
autoencoder .tiled_image_to_latents (sample_image )
0 commit comments