Skip to content

Commit

Permalink
[Tests] Fix ControlNet Single File tests (huggingface#7315)
Browse files Browse the repository at this point in the history
* update

* update

---------

Co-authored-by: Sayak Paul <[email protected]>
  • Loading branch information
DN6 and sayakpaul authored Mar 18, 2024
1 parent 76de6a0 commit 4330a74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/pipelines/controlnet/test_controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,13 @@ def test_single_file_component_configs(self):
for param_name, param_value in single_file_pipe.controlnet.config.items():
if param_name in PARAMS_TO_IGNORE:
continue

# This parameter doesn't appear to be loaded from the config.
# So when it is registered to config, it remains a tuple as this is the default in the class definition
# from_pretrained, does load from config and converts to a list when registering to config
if param_name == "conditioning_embedding_out_channels" and isinstance(param_value, tuple):
param_value = list(param_value)

assert (
pipe.controlnet.config[param_name] == param_value
), f"{param_name} differs between single file loading and pretrained loading"
Expand Down
5 changes: 5 additions & 0 deletions tests/pipelines/controlnet/test_controlnet_sdxl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,11 @@ def test_single_file_component_configs(self):
for param_name, param_value in single_file_pipe.unet.config.items():
if param_name in PARAMS_TO_IGNORE:
continue

# Upcast attention might be set to None in a config file, which is incorrect. It should default to False in the model
if param_name == "upcast_attention" and pipe.unet.config[param_name] is None:
pipe.unet.config[param_name] = False

assert (
pipe.unet.config[param_name] == param_value
), f"{param_name} differs between single file loading and pretrained loading"
Expand Down

0 comments on commit 4330a74

Please sign in to comment.