Skip to content

Commit 17c2c06

Browse files
[Tests] Fix slow tests (#1087)
1 parent 010bc4e commit 17c2c06

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/diffusers/configuration_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def extract_init_dict(cls, config_dict, **kwargs):
323323

324324
# remove attributes from orig class that cannot be expected
325325
orig_cls_name = config_dict.pop("_class_name", cls.__name__)
326-
if orig_cls_name != cls.__name__:
326+
if orig_cls_name != cls.__name__ and hasattr(diffusers_library, orig_cls_name):
327327
orig_cls = getattr(diffusers_library, orig_cls_name)
328328
unexpected_keys_from_orig = cls._get_init_keys(orig_cls) - expected_keys
329329
config_dict = {k: v for k, v in config_dict.items() if k not in unexpected_keys_from_orig}

src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,18 @@ def __init__(
9090
new_config["steps_offset"] = 1
9191
scheduler._internal_dict = FrozenDict(new_config)
9292

93-
if hasattr(scheduler.config, "clip_sample") and scheduler.config.clip_sample is True:
93+
if hasattr(scheduler.config, "skip_prk_steps") and scheduler.config.skip_prk_steps is False:
9494
deprecation_message = (
95-
f"The configuration file of this scheduler: {scheduler} has not set the configuration `clip_sample`."
96-
" `clip_sample` should be set to False in the configuration file. Please make sure to update the"
97-
" config accordingly as not setting `clip_sample` in the config might lead to incorrect results in"
98-
" future versions. If you have downloaded this checkpoint from the Hugging Face Hub, it would be very"
99-
" nice if you could open a Pull request for the `scheduler/scheduler_config.json` file"
95+
f"The configuration file of this scheduler: {scheduler} has not set the configuration"
96+
" `skip_prk_steps`. `skip_prk_steps` should be set to True in the configuration file. Please make"
97+
" sure to update the config accordingly as not setting `skip_prk_steps` in the config might lead to"
98+
" incorrect results in future versions. If you have downloaded this checkpoint from the Hugging Face"
99+
" Hub, it would be very nice if you could open a Pull request for the"
100+
" `scheduler/scheduler_config.json` file"
100101
)
101-
deprecate("clip_sample not set", "1.0.0", deprecation_message, standard_warn=False)
102+
deprecate("skip_prk_steps not set", "1.0.0", deprecation_message, standard_warn=False)
102103
new_config = dict(scheduler.config)
103-
new_config["clip_sample"] = False
104+
new_config["skip_prk_steps"] = True
104105
scheduler._internal_dict = FrozenDict(new_config)
105106

106107
if safety_checker is None:

tests/pipelines/stable_diffusion/test_stable_diffusion.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,13 +640,14 @@ def test_stable_diffusion(self):
640640
assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2
641641

642642
def test_stable_diffusion_fast_ddim(self):
643-
sd_pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-1", device_map="auto")
643+
scheduler = DDIMScheduler.from_config("CompVis/stable-diffusion-v1-1", subfolder="scheduler")
644+
645+
sd_pipe = StableDiffusionPipeline.from_pretrained(
646+
"CompVis/stable-diffusion-v1-1", scheduler=scheduler, device_map="auto"
647+
)
644648
sd_pipe = sd_pipe.to(torch_device)
645649
sd_pipe.set_progress_bar_config(disable=None)
646650

647-
scheduler = DDIMScheduler.from_config("CompVis/stable-diffusion-v1-1", subfolder="scheduler")
648-
sd_pipe.scheduler = scheduler
649-
650651
prompt = "A painting of a squirrel eating a burger"
651652
generator = torch.Generator(device=torch_device).manual_seed(0)
652653

0 commit comments

Comments
 (0)