Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
9a349538
Unverified
Commit
9a349538
authored
Mar 25, 2024
by
Dhruv Nair
Committed by
GitHub
Mar 25, 2024
Browse files
Additional Memory clean up for slow tests (#7436)
* update * update * update
parent
e29f16cf
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
162 additions
and
29 deletions
+162
-29
tests/pipelines/deepfloyd_if/test_if.py
tests/pipelines/deepfloyd_if/test_if.py
+6
-0
tests/pipelines/deepfloyd_if/test_if_img2img.py
tests/pipelines/deepfloyd_if/test_if_img2img.py
+10
-0
tests/pipelines/deepfloyd_if/test_if_img2img_superresolution.py
...pipelines/deepfloyd_if/test_if_img2img_superresolution.py
+10
-0
tests/pipelines/deepfloyd_if/test_if_inpainting.py
tests/pipelines/deepfloyd_if/test_if_inpainting.py
+6
-1
tests/pipelines/deepfloyd_if/test_if_inpainting_superresolution.py
...elines/deepfloyd_if/test_if_inpainting_superresolution.py
+6
-0
tests/pipelines/deepfloyd_if/test_if_superresolution.py
tests/pipelines/deepfloyd_if/test_if_superresolution.py
+6
-0
tests/pipelines/ip_adapters/test_ip_adapter_stable_diffusion.py
...pipelines/ip_adapters/test_ip_adapter_stable_diffusion.py
+12
-5
tests/pipelines/kandinsky/test_kandinsky.py
tests/pipelines/kandinsky/test_kandinsky.py
+6
-0
tests/pipelines/kandinsky/test_kandinsky_img2img.py
tests/pipelines/kandinsky/test_kandinsky_img2img.py
+6
-0
tests/pipelines/kandinsky/test_kandinsky_inpaint.py
tests/pipelines/kandinsky/test_kandinsky_inpaint.py
+6
-0
tests/pipelines/kandinsky2_2/test_kandinsky.py
tests/pipelines/kandinsky2_2/test_kandinsky.py
+10
-5
tests/pipelines/kandinsky2_2/test_kandinsky_controlnet.py
tests/pipelines/kandinsky2_2/test_kandinsky_controlnet.py
+10
-5
tests/pipelines/kandinsky2_2/test_kandinsky_controlnet_img2img.py
...pelines/kandinsky2_2/test_kandinsky_controlnet_img2img.py
+10
-4
tests/pipelines/kandinsky2_2/test_kandinsky_img2img.py
tests/pipelines/kandinsky2_2/test_kandinsky_img2img.py
+9
-4
tests/pipelines/kandinsky2_2/test_kandinsky_inpaint.py
tests/pipelines/kandinsky2_2/test_kandinsky_inpaint.py
+8
-2
tests/pipelines/kandinsky3/test_kandinsky3.py
tests/pipelines/kandinsky3/test_kandinsky3.py
+8
-2
tests/pipelines/kandinsky3/test_kandinsky3_img2img.py
tests/pipelines/kandinsky3/test_kandinsky3_img2img.py
+7
-1
tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl_img2img.py
...s/stable_diffusion_xl/test_stable_diffusion_xl_img2img.py
+7
-0
tests/pipelines/test_pipelines_common.py
tests/pipelines/test_pipelines_common.py
+6
-0
tests/pipelines/text_to_video_synthesis/test_text_to_video.py
...s/pipelines/text_to_video_synthesis/test_text_to_video.py
+13
-0
No files found.
tests/pipelines/deepfloyd_if/test_if.py
View file @
9a349538
...
@@ -85,6 +85,12 @@ class IFPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMixin, unittest.T
...
@@ -85,6 +85,12 @@ class IFPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMixin, unittest.T
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
IFPipelineSlowTests
(
unittest
.
TestCase
):
class
IFPipelineSlowTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
...
tests/pipelines/deepfloyd_if/test_if_img2img.py
View file @
9a349538
...
@@ -94,6 +94,12 @@ class IFImg2ImgPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMixin, uni
...
@@ -94,6 +94,12 @@ class IFImg2ImgPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMixin, uni
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
IFImg2ImgPipelineSlowTests
(
unittest
.
TestCase
):
class
IFImg2ImgPipelineSlowTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -109,6 +115,10 @@ class IFImg2ImgPipelineSlowTests(unittest.TestCase):
...
@@ -109,6 +115,10 @@ class IFImg2ImgPipelineSlowTests(unittest.TestCase):
pipe
.
unet
.
set_attn_processor
(
AttnAddedKVProcessor
())
pipe
.
unet
.
set_attn_processor
(
AttnAddedKVProcessor
())
pipe
.
enable_model_cpu_offload
()
pipe
.
enable_model_cpu_offload
()
torch
.
cuda
.
reset_max_memory_allocated
()
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
reset_peak_memory_stats
()
image
=
floats_tensor
((
1
,
3
,
64
,
64
),
rng
=
random
.
Random
(
0
)).
to
(
torch_device
)
image
=
floats_tensor
((
1
,
3
,
64
,
64
),
rng
=
random
.
Random
(
0
)).
to
(
torch_device
)
generator
=
torch
.
Generator
(
device
=
"cpu"
).
manual_seed
(
0
)
generator
=
torch
.
Generator
(
device
=
"cpu"
).
manual_seed
(
0
)
output
=
pipe
(
output
=
pipe
(
...
...
tests/pipelines/deepfloyd_if/test_if_img2img_superresolution.py
View file @
9a349538
...
@@ -92,6 +92,12 @@ class IFImg2ImgSuperResolutionPipelineFastTests(PipelineTesterMixin, IFPipelineT
...
@@ -92,6 +92,12 @@ class IFImg2ImgSuperResolutionPipelineFastTests(PipelineTesterMixin, IFPipelineT
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
IFImg2ImgSuperResolutionPipelineSlowTests
(
unittest
.
TestCase
):
class
IFImg2ImgSuperResolutionPipelineSlowTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -107,6 +113,10 @@ class IFImg2ImgSuperResolutionPipelineSlowTests(unittest.TestCase):
...
@@ -107,6 +113,10 @@ class IFImg2ImgSuperResolutionPipelineSlowTests(unittest.TestCase):
pipe
.
unet
.
set_attn_processor
(
AttnAddedKVProcessor
())
pipe
.
unet
.
set_attn_processor
(
AttnAddedKVProcessor
())
pipe
.
enable_model_cpu_offload
()
pipe
.
enable_model_cpu_offload
()
torch
.
cuda
.
reset_max_memory_allocated
()
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
reset_peak_memory_stats
()
generator
=
torch
.
Generator
(
device
=
"cpu"
).
manual_seed
(
0
)
generator
=
torch
.
Generator
(
device
=
"cpu"
).
manual_seed
(
0
)
original_image
=
floats_tensor
((
1
,
3
,
256
,
256
),
rng
=
random
.
Random
(
0
)).
to
(
torch_device
)
original_image
=
floats_tensor
((
1
,
3
,
256
,
256
),
rng
=
random
.
Random
(
0
)).
to
(
torch_device
)
...
...
tests/pipelines/deepfloyd_if/test_if_inpainting.py
View file @
9a349538
...
@@ -92,6 +92,12 @@ class IFInpaintingPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMixin,
...
@@ -92,6 +92,12 @@ class IFInpaintingPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMixin,
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
IFInpaintingPipelineSlowTests
(
unittest
.
TestCase
):
class
IFInpaintingPipelineSlowTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -105,7 +111,6 @@ class IFInpaintingPipelineSlowTests(unittest.TestCase):
...
@@ -105,7 +111,6 @@ class IFInpaintingPipelineSlowTests(unittest.TestCase):
pipe
.
unet
.
set_attn_processor
(
AttnAddedKVProcessor
())
pipe
.
unet
.
set_attn_processor
(
AttnAddedKVProcessor
())
pipe
.
enable_model_cpu_offload
()
pipe
.
enable_model_cpu_offload
()
# Super resolution test
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
reset_max_memory_allocated
()
torch
.
cuda
.
reset_max_memory_allocated
()
torch
.
cuda
.
reset_peak_memory_stats
()
torch
.
cuda
.
reset_peak_memory_stats
()
...
...
tests/pipelines/deepfloyd_if/test_if_inpainting_superresolution.py
View file @
9a349538
...
@@ -94,6 +94,12 @@ class IFInpaintingSuperResolutionPipelineFastTests(PipelineTesterMixin, IFPipeli
...
@@ -94,6 +94,12 @@ class IFInpaintingSuperResolutionPipelineFastTests(PipelineTesterMixin, IFPipeli
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
IFInpaintingSuperResolutionPipelineSlowTests
(
unittest
.
TestCase
):
class
IFInpaintingSuperResolutionPipelineSlowTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
...
tests/pipelines/deepfloyd_if/test_if_superresolution.py
View file @
9a349538
...
@@ -87,6 +87,12 @@ class IFSuperResolutionPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMi
...
@@ -87,6 +87,12 @@ class IFSuperResolutionPipelineFastTests(PipelineTesterMixin, IFPipelineTesterMi
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
IFSuperResolutionPipelineSlowTests
(
unittest
.
TestCase
):
class
IFSuperResolutionPipelineSlowTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
...
tests/pipelines/ip_adapters/test_ip_adapter_stable_diffusion.py
View file @
9a349538
...
@@ -50,7 +50,14 @@ enable_full_determinism()
...
@@ -50,7 +50,14 @@ enable_full_determinism()
class
IPAdapterNightlyTestsMixin
(
unittest
.
TestCase
):
class
IPAdapterNightlyTestsMixin
(
unittest
.
TestCase
):
dtype
=
torch
.
float16
dtype
=
torch
.
float16
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
gc
.
collect
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
empty_cache
()
...
@@ -313,7 +320,7 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
...
@@ -313,7 +320,7 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
feature_extractor
=
feature_extractor
,
feature_extractor
=
feature_extractor
,
torch_dtype
=
self
.
dtype
,
torch_dtype
=
self
.
dtype
,
)
)
pipeline
.
to
(
torch_device
)
pipeline
.
enable_model_cpu_offload
(
)
pipeline
.
load_ip_adapter
(
"h94/IP-Adapter"
,
subfolder
=
"sdxl_models"
,
weight_name
=
"ip-adapter_sdxl.bin"
)
pipeline
.
load_ip_adapter
(
"h94/IP-Adapter"
,
subfolder
=
"sdxl_models"
,
weight_name
=
"ip-adapter_sdxl.bin"
)
inputs
=
self
.
get_dummy_inputs
()
inputs
=
self
.
get_dummy_inputs
()
...
@@ -373,7 +380,7 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
...
@@ -373,7 +380,7 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
feature_extractor
=
feature_extractor
,
feature_extractor
=
feature_extractor
,
torch_dtype
=
self
.
dtype
,
torch_dtype
=
self
.
dtype
,
)
)
pipeline
.
to
(
torch_device
)
pipeline
.
enable_model_cpu_offload
(
)
pipeline
.
load_ip_adapter
(
"h94/IP-Adapter"
,
subfolder
=
"sdxl_models"
,
weight_name
=
"ip-adapter_sdxl.bin"
)
pipeline
.
load_ip_adapter
(
"h94/IP-Adapter"
,
subfolder
=
"sdxl_models"
,
weight_name
=
"ip-adapter_sdxl.bin"
)
inputs
=
self
.
get_dummy_inputs
(
for_image_to_image
=
True
)
inputs
=
self
.
get_dummy_inputs
(
for_image_to_image
=
True
)
...
@@ -442,7 +449,7 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
...
@@ -442,7 +449,7 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
feature_extractor
=
feature_extractor
,
feature_extractor
=
feature_extractor
,
torch_dtype
=
self
.
dtype
,
torch_dtype
=
self
.
dtype
,
)
)
pipeline
.
to
(
torch_device
)
pipeline
.
enable_model_cpu_offload
(
)
pipeline
.
load_ip_adapter
(
"h94/IP-Adapter"
,
subfolder
=
"sdxl_models"
,
weight_name
=
"ip-adapter_sdxl.bin"
)
pipeline
.
load_ip_adapter
(
"h94/IP-Adapter"
,
subfolder
=
"sdxl_models"
,
weight_name
=
"ip-adapter_sdxl.bin"
)
inputs
=
self
.
get_dummy_inputs
(
for_inpainting
=
True
)
inputs
=
self
.
get_dummy_inputs
(
for_inpainting
=
True
)
...
@@ -490,7 +497,7 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
...
@@ -490,7 +497,7 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
image_encoder
=
image_encoder
,
image_encoder
=
image_encoder
,
torch_dtype
=
self
.
dtype
,
torch_dtype
=
self
.
dtype
,
)
)
pipeline
.
to
(
torch_device
)
pipeline
.
enable_model_cpu_offload
(
)
pipeline
.
load_ip_adapter
(
pipeline
.
load_ip_adapter
(
"h94/IP-Adapter"
,
subfolder
=
"sdxl_models"
,
weight_name
=
"ip-adapter-plus-face_sdxl_vit-h.safetensors"
"h94/IP-Adapter"
,
subfolder
=
"sdxl_models"
,
weight_name
=
"ip-adapter-plus-face_sdxl_vit-h.safetensors"
)
)
...
@@ -518,7 +525,7 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
...
@@ -518,7 +525,7 @@ class IPAdapterSDXLIntegrationTests(IPAdapterNightlyTestsMixin):
image_encoder
=
image_encoder
,
image_encoder
=
image_encoder
,
torch_dtype
=
self
.
dtype
,
torch_dtype
=
self
.
dtype
,
)
)
pipeline
.
to
(
torch_device
)
pipeline
.
enable_model_cpu_offload
(
)
pipeline
.
load_ip_adapter
(
pipeline
.
load_ip_adapter
(
"h94/IP-Adapter"
,
subfolder
=
"sdxl_models"
,
weight_name
=
[
"ip-adapter-plus-face_sdxl_vit-h.safetensors"
]
*
2
"h94/IP-Adapter"
,
subfolder
=
"sdxl_models"
,
weight_name
=
[
"ip-adapter-plus-face_sdxl_vit-h.safetensors"
]
*
2
)
)
...
...
tests/pipelines/kandinsky/test_kandinsky.py
View file @
9a349538
...
@@ -275,6 +275,12 @@ class KandinskyPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
...
@@ -275,6 +275,12 @@ class KandinskyPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
KandinskyPipelineIntegrationTests
(
unittest
.
TestCase
):
class
KandinskyPipelineIntegrationTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
...
tests/pipelines/kandinsky/test_kandinsky_img2img.py
View file @
9a349538
...
@@ -299,6 +299,12 @@ class KandinskyImg2ImgPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
...
@@ -299,6 +299,12 @@ class KandinskyImg2ImgPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
KandinskyImg2ImgPipelineIntegrationTests
(
unittest
.
TestCase
):
class
KandinskyImg2ImgPipelineIntegrationTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
...
tests/pipelines/kandinsky/test_kandinsky_inpaint.py
View file @
9a349538
...
@@ -297,6 +297,12 @@ class KandinskyInpaintPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
...
@@ -297,6 +297,12 @@ class KandinskyInpaintPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
@
nightly
@
nightly
@
require_torch_gpu
@
require_torch_gpu
class
KandinskyInpaintPipelineIntegrationTests
(
unittest
.
TestCase
):
class
KandinskyInpaintPipelineIntegrationTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
...
tests/pipelines/kandinsky2_2/test_kandinsky.py
View file @
9a349538
...
@@ -27,7 +27,6 @@ from diffusers.utils.testing_utils import (
...
@@ -27,7 +27,6 @@ from diffusers.utils.testing_utils import (
load_numpy
,
load_numpy
,
require_torch_gpu
,
require_torch_gpu
,
slow
,
slow
,
torch_device
,
)
)
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
...
@@ -223,6 +222,12 @@ class KandinskyV22PipelineFastTests(PipelineTesterMixin, unittest.TestCase):
...
@@ -223,6 +222,12 @@ class KandinskyV22PipelineFastTests(PipelineTesterMixin, unittest.TestCase):
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
KandinskyV22PipelineIntegrationTests
(
unittest
.
TestCase
):
class
KandinskyV22PipelineIntegrationTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -238,12 +243,12 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
...
@@ -238,12 +243,12 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
pipe_prior
=
KandinskyV22PriorPipeline
.
from_pretrained
(
pipe_prior
=
KandinskyV22PriorPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-prior"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-prior"
,
torch_dtype
=
torch
.
float16
)
)
pipe_prior
.
to
(
torch_device
)
pipe_prior
.
enable_model_cpu_offload
(
)
pipeline
=
KandinskyV22Pipeline
.
from_pretrained
(
pipeline
=
KandinskyV22Pipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-decoder"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-decoder"
,
torch_dtype
=
torch
.
float16
)
)
pipeline
=
pipeline
.
to
(
torch_device
)
pipeline
=
pipeline
.
enable_model_cpu_offload
(
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
prompt
=
"red cat, 4k photo"
prompt
=
"red cat, 4k photo"
...
@@ -252,7 +257,7 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
...
@@ -252,7 +257,7 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
image_emb
,
zero_image_emb
=
pipe_prior
(
image_emb
,
zero_image_emb
=
pipe_prior
(
prompt
,
prompt
,
generator
=
generator
,
generator
=
generator
,
num_inference_steps
=
5
,
num_inference_steps
=
3
,
negative_prompt
=
""
,
negative_prompt
=
""
,
).
to_tuple
()
).
to_tuple
()
...
@@ -261,7 +266,7 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
...
@@ -261,7 +266,7 @@ class KandinskyV22PipelineIntegrationTests(unittest.TestCase):
image_embeds
=
image_emb
,
image_embeds
=
image_emb
,
negative_image_embeds
=
zero_image_emb
,
negative_image_embeds
=
zero_image_emb
,
generator
=
generator
,
generator
=
generator
,
num_inference_steps
=
100
,
num_inference_steps
=
3
,
output_type
=
"np"
,
output_type
=
"np"
,
)
)
...
...
tests/pipelines/kandinsky2_2/test_kandinsky_controlnet.py
View file @
9a349538
...
@@ -34,7 +34,6 @@ from diffusers.utils.testing_utils import (
...
@@ -34,7 +34,6 @@ from diffusers.utils.testing_utils import (
load_numpy
,
load_numpy
,
nightly
,
nightly
,
require_torch_gpu
,
require_torch_gpu
,
torch_device
,
)
)
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
...
@@ -228,6 +227,12 @@ class KandinskyV22ControlnetPipelineFastTests(PipelineTesterMixin, unittest.Test
...
@@ -228,6 +227,12 @@ class KandinskyV22ControlnetPipelineFastTests(PipelineTesterMixin, unittest.Test
@
nightly
@
nightly
@
require_torch_gpu
@
require_torch_gpu
class
KandinskyV22ControlnetPipelineIntegrationTests
(
unittest
.
TestCase
):
class
KandinskyV22ControlnetPipelineIntegrationTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -250,12 +255,12 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
...
@@ -250,12 +255,12 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
pipe_prior
=
KandinskyV22PriorPipeline
.
from_pretrained
(
pipe_prior
=
KandinskyV22PriorPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-prior"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-prior"
,
torch_dtype
=
torch
.
float16
)
)
pipe_prior
.
to
(
torch_device
)
pipe_prior
.
enable_model_cpu_offload
(
)
pipeline
=
KandinskyV22ControlnetPipeline
.
from_pretrained
(
pipeline
=
KandinskyV22ControlnetPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-controlnet-depth"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-controlnet-depth"
,
torch_dtype
=
torch
.
float16
)
)
pipeline
=
pipeline
.
to
(
torch_device
)
pipeline
=
pipeline
.
enable_model_cpu_offload
(
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
prompt
=
"A robot, 4k photo"
prompt
=
"A robot, 4k photo"
...
@@ -264,7 +269,7 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
...
@@ -264,7 +269,7 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
image_emb
,
zero_image_emb
=
pipe_prior
(
image_emb
,
zero_image_emb
=
pipe_prior
(
prompt
,
prompt
,
generator
=
generator
,
generator
=
generator
,
num_inference_steps
=
5
,
num_inference_steps
=
2
,
negative_prompt
=
""
,
negative_prompt
=
""
,
).
to_tuple
()
).
to_tuple
()
...
@@ -274,7 +279,7 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
...
@@ -274,7 +279,7 @@ class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
negative_image_embeds
=
zero_image_emb
,
negative_image_embeds
=
zero_image_emb
,
hint
=
hint
,
hint
=
hint
,
generator
=
generator
,
generator
=
generator
,
num_inference_steps
=
100
,
num_inference_steps
=
2
,
output_type
=
"np"
,
output_type
=
"np"
,
)
)
...
...
tests/pipelines/kandinsky2_2/test_kandinsky_controlnet_img2img.py
View file @
9a349538
...
@@ -35,7 +35,6 @@ from diffusers.utils.testing_utils import (
...
@@ -35,7 +35,6 @@ from diffusers.utils.testing_utils import (
load_numpy
,
load_numpy
,
nightly
,
nightly
,
require_torch_gpu
,
require_torch_gpu
,
torch_device
,
)
)
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
...
@@ -235,6 +234,12 @@ class KandinskyV22ControlnetImg2ImgPipelineFastTests(PipelineTesterMixin, unitte
...
@@ -235,6 +234,12 @@ class KandinskyV22ControlnetImg2ImgPipelineFastTests(PipelineTesterMixin, unitte
@
nightly
@
nightly
@
require_torch_gpu
@
require_torch_gpu
class
KandinskyV22ControlnetImg2ImgPipelineIntegrationTests
(
unittest
.
TestCase
):
class
KandinskyV22ControlnetImg2ImgPipelineIntegrationTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -264,12 +269,12 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -264,12 +269,12 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
pipe_prior
=
KandinskyV22PriorEmb2EmbPipeline
.
from_pretrained
(
pipe_prior
=
KandinskyV22PriorEmb2EmbPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-prior"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-prior"
,
torch_dtype
=
torch
.
float16
)
)
pipe_prior
.
to
(
torch_device
)
pipe_prior
.
enable_model_cpu_offload
(
)
pipeline
=
KandinskyV22ControlnetImg2ImgPipeline
.
from_pretrained
(
pipeline
=
KandinskyV22ControlnetImg2ImgPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-controlnet-depth"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-controlnet-depth"
,
torch_dtype
=
torch
.
float16
)
)
pipeline
=
pipeline
.
to
(
torch_device
)
pipeline
=
pipeline
.
enable_model_cpu_offload
(
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
...
@@ -281,6 +286,7 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -281,6 +286,7 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
strength
=
0.85
,
strength
=
0.85
,
generator
=
generator
,
generator
=
generator
,
negative_prompt
=
""
,
negative_prompt
=
""
,
num_inference_steps
=
5
,
).
to_tuple
()
).
to_tuple
()
output
=
pipeline
(
output
=
pipeline
(
...
@@ -289,7 +295,7 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -289,7 +295,7 @@ class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
negative_image_embeds
=
zero_image_emb
,
negative_image_embeds
=
zero_image_emb
,
hint
=
hint
,
hint
=
hint
,
generator
=
generator
,
generator
=
generator
,
num_inference_steps
=
100
,
num_inference_steps
=
5
,
height
=
512
,
height
=
512
,
width
=
512
,
width
=
512
,
strength
=
0.5
,
strength
=
0.5
,
...
...
tests/pipelines/kandinsky2_2/test_kandinsky_img2img.py
View file @
9a349538
...
@@ -35,7 +35,6 @@ from diffusers.utils.testing_utils import (
...
@@ -35,7 +35,6 @@ from diffusers.utils.testing_utils import (
load_numpy
,
load_numpy
,
require_torch_gpu
,
require_torch_gpu
,
slow
,
slow
,
torch_device
,
)
)
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
from
..test_pipelines_common
import
PipelineTesterMixin
,
assert_mean_pixel_difference
...
@@ -240,6 +239,12 @@ class KandinskyV22Img2ImgPipelineFastTests(PipelineTesterMixin, unittest.TestCas
...
@@ -240,6 +239,12 @@ class KandinskyV22Img2ImgPipelineFastTests(PipelineTesterMixin, unittest.TestCas
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
KandinskyV22Img2ImgPipelineIntegrationTests
(
unittest
.
TestCase
):
class
KandinskyV22Img2ImgPipelineIntegrationTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -260,12 +265,12 @@ class KandinskyV22Img2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -260,12 +265,12 @@ class KandinskyV22Img2ImgPipelineIntegrationTests(unittest.TestCase):
pipe_prior
=
KandinskyV22PriorPipeline
.
from_pretrained
(
pipe_prior
=
KandinskyV22PriorPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-prior"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-prior"
,
torch_dtype
=
torch
.
float16
)
)
pipe_prior
.
to
(
torch_device
)
pipe_prior
.
enable_model_cpu_offload
(
)
pipeline
=
KandinskyV22Img2ImgPipeline
.
from_pretrained
(
pipeline
=
KandinskyV22Img2ImgPipeline
.
from_pretrained
(
"kandinsky-community/kandinsky-2-2-decoder"
,
torch_dtype
=
torch
.
float16
"kandinsky-community/kandinsky-2-2-decoder"
,
torch_dtype
=
torch
.
float16
)
)
pipeline
=
pipeline
.
to
(
torch_device
)
pipeline
=
pipeline
.
enable_model_cpu_offload
(
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
pipeline
.
set_progress_bar_config
(
disable
=
None
)
...
@@ -282,7 +287,7 @@ class KandinskyV22Img2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -282,7 +287,7 @@ class KandinskyV22Img2ImgPipelineIntegrationTests(unittest.TestCase):
image_embeds
=
image_emb
,
image_embeds
=
image_emb
,
negative_image_embeds
=
zero_image_emb
,
negative_image_embeds
=
zero_image_emb
,
generator
=
generator
,
generator
=
generator
,
num_inference_steps
=
100
,
num_inference_steps
=
5
,
height
=
768
,
height
=
768
,
width
=
768
,
width
=
768
,
strength
=
0.2
,
strength
=
0.2
,
...
...
tests/pipelines/kandinsky2_2/test_kandinsky_inpaint.py
View file @
9a349538
...
@@ -293,6 +293,12 @@ class KandinskyV22InpaintPipelineFastTests(PipelineTesterMixin, unittest.TestCas
...
@@ -293,6 +293,12 @@ class KandinskyV22InpaintPipelineFastTests(PipelineTesterMixin, unittest.TestCas
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
KandinskyV22InpaintPipelineIntegrationTests
(
unittest
.
TestCase
):
class
KandinskyV22InpaintPipelineIntegrationTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -328,7 +334,7 @@ class KandinskyV22InpaintPipelineIntegrationTests(unittest.TestCase):
...
@@ -328,7 +334,7 @@ class KandinskyV22InpaintPipelineIntegrationTests(unittest.TestCase):
image_emb
,
zero_image_emb
=
pipe_prior
(
image_emb
,
zero_image_emb
=
pipe_prior
(
prompt
,
prompt
,
generator
=
generator
,
generator
=
generator
,
num_inference_steps
=
5
,
num_inference_steps
=
2
,
negative_prompt
=
""
,
negative_prompt
=
""
,
).
to_tuple
()
).
to_tuple
()
...
@@ -338,7 +344,7 @@ class KandinskyV22InpaintPipelineIntegrationTests(unittest.TestCase):
...
@@ -338,7 +344,7 @@ class KandinskyV22InpaintPipelineIntegrationTests(unittest.TestCase):
image_embeds
=
image_emb
,
image_embeds
=
image_emb
,
negative_image_embeds
=
zero_image_emb
,
negative_image_embeds
=
zero_image_emb
,
generator
=
generator
,
generator
=
generator
,
num_inference_steps
=
100
,
num_inference_steps
=
2
,
height
=
768
,
height
=
768
,
width
=
768
,
width
=
768
,
output_type
=
"np"
,
output_type
=
"np"
,
...
...
tests/pipelines/kandinsky3/test_kandinsky3.py
View file @
9a349538
...
@@ -169,6 +169,12 @@ class Kandinsky3PipelineFastTests(PipelineTesterMixin, unittest.TestCase):
...
@@ -169,6 +169,12 @@ class Kandinsky3PipelineFastTests(PipelineTesterMixin, unittest.TestCase):
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
Kandinsky3PipelineIntegrationTests
(
unittest
.
TestCase
):
class
Kandinsky3PipelineIntegrationTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -186,7 +192,7 @@ class Kandinsky3PipelineIntegrationTests(unittest.TestCase):
...
@@ -186,7 +192,7 @@ class Kandinsky3PipelineIntegrationTests(unittest.TestCase):
generator
=
torch
.
Generator
(
device
=
"cpu"
).
manual_seed
(
0
)
generator
=
torch
.
Generator
(
device
=
"cpu"
).
manual_seed
(
0
)
image
=
pipe
(
prompt
,
num_inference_steps
=
2
5
,
generator
=
generator
).
images
[
0
]
image
=
pipe
(
prompt
,
num_inference_steps
=
5
,
generator
=
generator
).
images
[
0
]
assert
image
.
size
==
(
1024
,
1024
)
assert
image
.
size
==
(
1024
,
1024
)
...
@@ -217,7 +223,7 @@ class Kandinsky3PipelineIntegrationTests(unittest.TestCase):
...
@@ -217,7 +223,7 @@ class Kandinsky3PipelineIntegrationTests(unittest.TestCase):
image
=
image
.
resize
((
w
,
h
),
resample
=
Image
.
BICUBIC
,
reducing_gap
=
1
)
image
=
image
.
resize
((
w
,
h
),
resample
=
Image
.
BICUBIC
,
reducing_gap
=
1
)
prompt
=
"A painting of the inside of a subway train with tiny raccoons."
prompt
=
"A painting of the inside of a subway train with tiny raccoons."
image
=
pipe
(
prompt
,
image
=
image
,
strength
=
0.75
,
num_inference_steps
=
2
5
,
generator
=
generator
).
images
[
0
]
image
=
pipe
(
prompt
,
image
=
image
,
strength
=
0.75
,
num_inference_steps
=
5
,
generator
=
generator
).
images
[
0
]
assert
image
.
size
==
(
512
,
512
)
assert
image
.
size
==
(
512
,
512
)
...
...
tests/pipelines/kandinsky3/test_kandinsky3_img2img.py
View file @
9a349538
...
@@ -187,6 +187,12 @@ class Kandinsky3Img2ImgPipelineFastTests(PipelineTesterMixin, unittest.TestCase)
...
@@ -187,6 +187,12 @@ class Kandinsky3Img2ImgPipelineFastTests(PipelineTesterMixin, unittest.TestCase)
@
slow
@
slow
@
require_torch_gpu
@
require_torch_gpu
class
Kandinsky3Img2ImgPipelineIntegrationTests
(
unittest
.
TestCase
):
class
Kandinsky3Img2ImgPipelineIntegrationTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -209,7 +215,7 @@ class Kandinsky3Img2ImgPipelineIntegrationTests(unittest.TestCase):
...
@@ -209,7 +215,7 @@ class Kandinsky3Img2ImgPipelineIntegrationTests(unittest.TestCase):
image
=
image
.
resize
((
w
,
h
),
resample
=
Image
.
BICUBIC
,
reducing_gap
=
1
)
image
=
image
.
resize
((
w
,
h
),
resample
=
Image
.
BICUBIC
,
reducing_gap
=
1
)
prompt
=
"A painting of the inside of a subway train with tiny raccoons."
prompt
=
"A painting of the inside of a subway train with tiny raccoons."
image
=
pipe
(
prompt
,
image
=
image
,
strength
=
0.75
,
num_inference_steps
=
2
5
,
generator
=
generator
).
images
[
0
]
image
=
pipe
(
prompt
,
image
=
image
,
strength
=
0.75
,
num_inference_steps
=
5
,
generator
=
generator
).
images
[
0
]
assert
image
.
size
==
(
512
,
512
)
assert
image
.
size
==
(
512
,
512
)
...
...
tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl_img2img.py
View file @
9a349538
...
@@ -779,7 +779,14 @@ class StableDiffusionXLImg2ImgRefinerOnlyPipelineFastTests(
...
@@ -779,7 +779,14 @@ class StableDiffusionXLImg2ImgRefinerOnlyPipelineFastTests(
@
slow
@
slow
class
StableDiffusionXLImg2ImgIntegrationTests
(
unittest
.
TestCase
):
class
StableDiffusionXLImg2ImgIntegrationTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
gc
.
collect
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
empty_cache
()
...
...
tests/pipelines/test_pipelines_common.py
View file @
9a349538
...
@@ -639,6 +639,12 @@ class PipelineTesterMixin:
...
@@ -639,6 +639,12 @@ class PipelineTesterMixin:
"`callback_cfg_params = TEXT_TO_IMAGE_CFG_PARAMS.union({'mask', 'masked_image_latents'})`"
"`callback_cfg_params = TEXT_TO_IMAGE_CFG_PARAMS.union({'mask', 'masked_image_latents'})`"
)
)
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test in case of CUDA runtime errors
# clean up the VRAM after each test in case of CUDA runtime errors
super
().
tearDown
()
super
().
tearDown
()
...
...
tests/pipelines/text_to_video_synthesis/test_text_to_video.py
View file @
9a349538
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
gc
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
...
@@ -183,6 +184,18 @@ class TextToVideoSDPipelineFastTests(PipelineTesterMixin, SDFunctionTesterMixin,
...
@@ -183,6 +184,18 @@ class TextToVideoSDPipelineFastTests(PipelineTesterMixin, SDFunctionTesterMixin,
@
skip_mps
@
skip_mps
@
require_torch_gpu
@
require_torch_gpu
class
TextToVideoSDPipelineSlowTests
(
unittest
.
TestCase
):
class
TextToVideoSDPipelineSlowTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
# clean up the VRAM before each test
super
().
setUp
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
tearDown
(
self
):
# clean up the VRAM after each test
super
().
tearDown
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
def
test_two_step_model
(
self
):
def
test_two_step_model
(
self
):
expected_video
=
load_numpy
(
expected_video
=
load_numpy
(
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/text-to-video/video_2step.npy"
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/text-to-video/video_2step.npy"
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment