@@ -1714,7 +1714,7 @@ def test_sdxl_0_9_lora_three(self):
1714
1714
release_memory (pipe )
1715
1715
1716
1716
def test_sdxl_1_0_lora (self ):
1717
- generator = torch .Generator ().manual_seed (0 )
1717
+ generator = torch .Generator ("cpu" ).manual_seed (0 )
1718
1718
1719
1719
pipe = DiffusionPipeline .from_pretrained ("stabilityai/stable-diffusion-xl-base-1.0" )
1720
1720
pipe .enable_model_cpu_offload ()
@@ -1737,7 +1737,7 @@ def test_sdxl_lcm_lora(self):
1737
1737
pipe .scheduler = LCMScheduler .from_config (pipe .scheduler .config )
1738
1738
pipe .enable_model_cpu_offload ()
1739
1739
1740
- generator = torch .Generator ().manual_seed (0 )
1740
+ generator = torch .Generator ("cpu" ).manual_seed (0 )
1741
1741
1742
1742
lora_model_id = "latent-consistency/lcm-lora-sdxl"
1743
1743
@@ -1766,7 +1766,7 @@ def test_sdv1_5_lcm_lora(self):
1766
1766
pipe .to ("cuda" )
1767
1767
pipe .scheduler = LCMScheduler .from_config (pipe .scheduler .config )
1768
1768
1769
- generator = torch .Generator ().manual_seed (0 )
1769
+ generator = torch .Generator ("cpu" ).manual_seed (0 )
1770
1770
1771
1771
lora_model_id = "latent-consistency/lcm-lora-sdv1-5"
1772
1772
pipe .load_lora_weights (lora_model_id )
@@ -1798,7 +1798,7 @@ def test_sdv1_5_lcm_lora_img2img(self):
1798
1798
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/img2img/fantasy_landscape.png"
1799
1799
)
1800
1800
1801
- generator = torch .Generator ().manual_seed (0 )
1801
+ generator = torch .Generator ("cpu" ).manual_seed (0 )
1802
1802
1803
1803
lora_model_id = "latent-consistency/lcm-lora-sdv1-5"
1804
1804
pipe .load_lora_weights (lora_model_id )
@@ -1866,15 +1866,13 @@ def test_sdxl_1_0_lora_unfusion(self):
1866
1866
images = pipe (
1867
1867
"masterpiece, best quality, mountain" , output_type = "pil" , generator = generator , num_inference_steps = 3
1868
1868
).images
1869
- images [0 ].save ("fused.png" )
1870
1869
images_with_fusion = images .flatten ()
1871
1870
1872
1871
pipe .unfuse_lora ()
1873
1872
generator = torch .Generator ("cpu" ).manual_seed (0 )
1874
1873
images = pipe (
1875
1874
"masterpiece, best quality, mountain" , output_type = "pil" , generator = generator , num_inference_steps = 3
1876
1875
).images
1877
- images [0 ].save ("unfused.png" )
1878
1876
images_without_fusion = images .flatten ()
1879
1877
1880
1878
self .assertTrue (np .allclose (images_with_fusion , images_without_fusion , atol = 1e-3 ))
0 commit comments