From 4330a747d457ff2af1ba89e94c57a6e19efffdb9 Mon Sep 17 00:00:00 2001 From: Dhruv Nair Date: Mon, 18 Mar 2024 11:28:59 +0530 Subject: [PATCH] [Tests] Fix ControlNet Single File tests (#7315) * update * update --------- Co-authored-by: Sayak Paul --- tests/pipelines/controlnet/test_controlnet.py | 7 +++++++ tests/pipelines/controlnet/test_controlnet_sdxl.py | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/tests/pipelines/controlnet/test_controlnet.py b/tests/pipelines/controlnet/test_controlnet.py index bd6330c12c..eb019fe026 100644 --- a/tests/pipelines/controlnet/test_controlnet.py +++ b/tests/pipelines/controlnet/test_controlnet.py @@ -1092,6 +1092,13 @@ class ControlNetPipelineSlowTests(unittest.TestCase): 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" diff --git a/tests/pipelines/controlnet/test_controlnet_sdxl.py b/tests/pipelines/controlnet/test_controlnet_sdxl.py index c82ce6c39c..6eadd7e1fa 100644 --- a/tests/pipelines/controlnet/test_controlnet_sdxl.py +++ b/tests/pipelines/controlnet/test_controlnet_sdxl.py @@ -1002,6 +1002,11 @@ class ControlNetSDXLPipelineSlowTests(unittest.TestCase): 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"