3737
3838enable_full_determinism ()
3939
40+ 
4041class  StableDiffusion3PAGImg2ImgPipelineFastTests (unittest .TestCase , PipelineTesterMixin ):
4142    pipeline_class  =  StableDiffusion3PAGImg2ImgPipeline 
4243    params  =  TEXT_GUIDED_IMAGE_VARIATION_PARAMS .union ({"pag_scale" , "pag_adaptive_scale" }) -  {"height" , "width" }
@@ -176,7 +177,6 @@ def test_pag_inference(self):
176177        inputs  =  self .get_dummy_inputs (device )
177178        image  =  pipe_pag (** inputs ).images 
178179        image_slice  =  image [0 , - 3 :, - 3 :, - 1 ]
179-         print (f"{ image_slice = }  )
180180
181181        assert  image .shape  ==  (
182182            1 ,
@@ -185,12 +185,10 @@ def test_pag_inference(self):
185185            3 ,
186186        ), f"the shape of the output image should be (1, 32, 32, 3) but got { image .shape }  
187187
188-         expected_slice  =  np .array ([
189-             [0.7251651 , 0.52043426 , 0.5527822 ],
190-             [0.7089102 , 0.62233330 , 0.5923926 ],
191-             [0.4929751 , 0.52322210 , 0.5529656 ]
192-         ])
193-         max_diff  =  np .abs (image_slice .flatten () -  expected_slice .flatten ()).max ()
188+         expected_slice  =  np .array (
189+             [0.7251651 , 0.52043426 , 0.5527822 , 0.7089102 , 0.62233330 , 0.5923926 , 0.4929751 , 0.52322210 , 0.5529656 ]
190+         )
191+         max_diff  =  np .abs (image_slice .flatten () -  expected_slice ).max ()
194192        self .assertLessEqual (max_diff , 1e-3 )
195193
196194
@@ -210,7 +208,9 @@ def tearDown(self):
210208        gc .collect ()
211209        torch .cuda .empty_cache ()
212210
213-     def  get_inputs (self , device , generator_device = "cpu" , dtype = torch .float32 , seed = 0 , guidance_scale = 7.0 , pag_scale = 0.7 ):
211+     def  get_inputs (
212+         self , device , generator_device = "cpu" , dtype = torch .float32 , seed = 0 , guidance_scale = 7.0 , pag_scale = 0.7 
213+     ):
214214        img_url  =  (
215215            "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl-text2img.png" 
216216        )
@@ -230,7 +230,9 @@ def get_inputs(self, device, generator_device="cpu", dtype=torch.float32, seed=0
230230        return  inputs 
231231
232232    def  test_pag_cfg (self ):
233-         pipeline  =  AutoPipelineForImage2Image .from_pretrained (self .repo_id , enable_pag = True , torch_dtype = torch .float16 , pag_applied_layers = ["blocks.17" ])
233+         pipeline  =  AutoPipelineForImage2Image .from_pretrained (
234+             self .repo_id , enable_pag = True , torch_dtype = torch .float16 , pag_applied_layers = ["blocks.17" ]
235+         )
234236        pipeline .enable_model_cpu_offload ()
235237        pipeline .set_progress_bar_config (disable = None )
236238
@@ -246,7 +248,9 @@ def test_pag_cfg(self):
246248        ), f"output is different from expected, { image_slice .flatten ()}  
247249
248250    def  test_pag_uncond (self ):
249-         pipeline  =  AutoPipelineForImage2Image .from_pretrained (self .repo_id , enable_pag = True , torch_dtype = torch .float16 , pag_applied_layers = ["blocks.(4|17)" ])
251+         pipeline  =  AutoPipelineForImage2Image .from_pretrained (
252+             self .repo_id , enable_pag = True , torch_dtype = torch .float16 , pag_applied_layers = ["blocks.(4|17)" ]
253+         )
250254        pipeline .enable_model_cpu_offload ()
251255        pipeline .set_progress_bar_config (disable = None )
252256
0 commit comments