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
20fd00b1
Unverified
Commit
20fd00b1
authored
Sep 30, 2025
by
Dhruv Nair
Committed by
GitHub
Sep 30, 2025
Browse files
[Tests] Add single file tester mixin for Models and remove unittest dependency (#12352)
* update * update * update * update * update
parent
76d4e416
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
19 deletions
+10
-19
tests/single_file/test_stable_diffusion_xl_img2img_single_file.py
...ngle_file/test_stable_diffusion_xl_img2img_single_file.py
+4
-7
tests/single_file/test_stable_diffusion_xl_instruct_pix2pix.py
.../single_file/test_stable_diffusion_xl_instruct_pix2pix.py
+3
-6
tests/single_file/test_stable_diffusion_xl_single_file.py
tests/single_file/test_stable_diffusion_xl_single_file.py
+3
-6
No files found.
tests/single_file/test_stable_diffusion_xl_img2img_single_file.py
View file @
20fd00b1
import
gc
import
gc
import
unittest
import
torch
import
torch
...
@@ -25,7 +24,7 @@ enable_full_determinism()
...
@@ -25,7 +24,7 @@ enable_full_determinism()
@
slow
@
slow
@
require_torch_accelerator
@
require_torch_accelerator
class
StableDiffusionXLImg2ImgPipelineSingleFileSlow
Tests
(
unittest
.
TestCase
,
SDXLSingleFileTesterMixin
):
class
Test
StableDiffusionXLImg2ImgPipelineSingleFileSlow
(
SDXLSingleFileTesterMixin
):
pipeline_class
=
StableDiffusionXLImg2ImgPipeline
pipeline_class
=
StableDiffusionXLImg2ImgPipeline
ckpt_path
=
"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0.safetensors"
ckpt_path
=
"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0.safetensors"
repo_id
=
"stabilityai/stable-diffusion-xl-base-1.0"
repo_id
=
"stabilityai/stable-diffusion-xl-base-1.0"
...
@@ -33,13 +32,11 @@ class StableDiffusionXLImg2ImgPipelineSingleFileSlowTests(unittest.TestCase, SDX
...
@@ -33,13 +32,11 @@ class StableDiffusionXLImg2ImgPipelineSingleFileSlowTests(unittest.TestCase, SDX
"https://raw.githubusercontent.com/Stability-AI/generative-models/main/configs/inference/sd_xl_base.yaml"
"https://raw.githubusercontent.com/Stability-AI/generative-models/main/configs/inference/sd_xl_base.yaml"
)
)
def
setUp
(
self
):
def
setup_method
(
self
):
super
().
setUp
()
gc
.
collect
()
gc
.
collect
()
backend_empty_cache
(
torch_device
)
backend_empty_cache
(
torch_device
)
def
tearDown
(
self
):
def
teardown_method
(
self
):
super
().
tearDown
()
gc
.
collect
()
gc
.
collect
()
backend_empty_cache
(
torch_device
)
backend_empty_cache
(
torch_device
)
...
@@ -66,7 +63,7 @@ class StableDiffusionXLImg2ImgPipelineSingleFileSlowTests(unittest.TestCase, SDX
...
@@ -66,7 +63,7 @@ class StableDiffusionXLImg2ImgPipelineSingleFileSlowTests(unittest.TestCase, SDX
@
slow
@
slow
@
require_torch_accelerator
@
require_torch_accelerator
class
StableDiffusionXLImg2ImgRefinerPipelineSingleFileSlowTests
(
unittest
.
TestCase
)
:
class
StableDiffusionXLImg2ImgRefinerPipelineSingleFileSlowTests
:
pipeline_class
=
StableDiffusionXLImg2ImgPipeline
pipeline_class
=
StableDiffusionXLImg2ImgPipeline
ckpt_path
=
(
ckpt_path
=
(
"https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/blob/main/sd_xl_refiner_1.0.safetensors"
"https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/blob/main/sd_xl_refiner_1.0.safetensors"
...
...
tests/single_file/test_stable_diffusion_xl_instruct_pix2pix.py
View file @
20fd00b1
import
gc
import
gc
import
unittest
import
torch
import
torch
...
@@ -19,19 +18,17 @@ enable_full_determinism()
...
@@ -19,19 +18,17 @@ enable_full_determinism()
@
slow
@
slow
@
require_torch_accelerator
@
require_torch_accelerator
class
StableDiffusionXLInstructPix2PixPipeline
(
unittest
.
TestCase
)
:
class
StableDiffusionXLInstructPix2PixPipeline
:
pipeline_class
=
StableDiffusionXLInstructPix2PixPipeline
pipeline_class
=
StableDiffusionXLInstructPix2PixPipeline
ckpt_path
=
"https://huggingface.co/stabilityai/cosxl/blob/main/cosxl_edit.safetensors"
ckpt_path
=
"https://huggingface.co/stabilityai/cosxl/blob/main/cosxl_edit.safetensors"
original_config
=
None
original_config
=
None
repo_id
=
"diffusers/sdxl-instructpix2pix-768"
repo_id
=
"diffusers/sdxl-instructpix2pix-768"
def
setUp
(
self
):
def
setup_method
(
self
):
super
().
setUp
()
gc
.
collect
()
gc
.
collect
()
backend_empty_cache
(
torch_device
)
backend_empty_cache
(
torch_device
)
def
tearDown
(
self
):
def
teardown_method
(
self
):
super
().
tearDown
()
gc
.
collect
()
gc
.
collect
()
backend_empty_cache
(
torch_device
)
backend_empty_cache
(
torch_device
)
...
...
tests/single_file/test_stable_diffusion_xl_single_file.py
View file @
20fd00b1
import
gc
import
gc
import
unittest
import
torch
import
torch
...
@@ -22,7 +21,7 @@ enable_full_determinism()
...
@@ -22,7 +21,7 @@ enable_full_determinism()
@
slow
@
slow
@
require_torch_accelerator
@
require_torch_accelerator
class
StableDiffusionXLPipelineSingleFileSlow
Tests
(
unittest
.
TestCase
,
SDXLSingleFileTesterMixin
):
class
Test
StableDiffusionXLPipelineSingleFileSlow
(
SDXLSingleFileTesterMixin
):
pipeline_class
=
StableDiffusionXLPipeline
pipeline_class
=
StableDiffusionXLPipeline
ckpt_path
=
"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0.safetensors"
ckpt_path
=
"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0.safetensors"
repo_id
=
"stabilityai/stable-diffusion-xl-base-1.0"
repo_id
=
"stabilityai/stable-diffusion-xl-base-1.0"
...
@@ -30,13 +29,11 @@ class StableDiffusionXLPipelineSingleFileSlowTests(unittest.TestCase, SDXLSingle
...
@@ -30,13 +29,11 @@ class StableDiffusionXLPipelineSingleFileSlowTests(unittest.TestCase, SDXLSingle
"https://raw.githubusercontent.com/Stability-AI/generative-models/main/configs/inference/sd_xl_base.yaml"
"https://raw.githubusercontent.com/Stability-AI/generative-models/main/configs/inference/sd_xl_base.yaml"
)
)
def
setUp
(
self
):
def
setup_method
(
self
):
super
().
setUp
()
gc
.
collect
()
gc
.
collect
()
backend_empty_cache
(
torch_device
)
backend_empty_cache
(
torch_device
)
def
tearDown
(
self
):
def
teardown_method
(
self
):
super
().
tearDown
()
gc
.
collect
()
gc
.
collect
()
backend_empty_cache
(
torch_device
)
backend_empty_cache
(
torch_device
)
...
...
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