Unverified Commit edc154da authored by Dhruv Nair's avatar Dhruv Nair Committed by GitHub
Browse files

Update Ruff to latest Version (#10919)

* update

* update

* update

* update
parent 552cd320
...@@ -191,12 +191,12 @@ class SDFunctionTesterMixin: ...@@ -191,12 +191,12 @@ class SDFunctionTesterMixin:
inputs["output_type"] = "np" inputs["output_type"] = "np"
output_no_freeu = pipe(**inputs)[0] output_no_freeu = pipe(**inputs)[0]
assert not np.allclose( assert not np.allclose(output[0, -3:, -3:, -1], output_freeu[0, -3:, -3:, -1]), (
output[0, -3:, -3:, -1], output_freeu[0, -3:, -3:, -1] "Enabling of FreeU should lead to different results."
), "Enabling of FreeU should lead to different results." )
assert np.allclose( assert np.allclose(output, output_no_freeu, atol=1e-2), (
output, output_no_freeu, atol=1e-2 f"Disabling of FreeU should lead to results similar to the default pipeline results but Max Abs Error={np.abs(output_no_freeu - output).max()}."
), f"Disabling of FreeU should lead to results similar to the default pipeline results but Max Abs Error={np.abs(output_no_freeu - output).max()}." )
def test_fused_qkv_projections(self): def test_fused_qkv_projections(self):
device = "cpu" # ensure determinism for the device-dependent torch.Generator device = "cpu" # ensure determinism for the device-dependent torch.Generator
...@@ -217,12 +217,12 @@ class SDFunctionTesterMixin: ...@@ -217,12 +217,12 @@ class SDFunctionTesterMixin:
and hasattr(component, "original_attn_processors") and hasattr(component, "original_attn_processors")
and component.original_attn_processors is not None and component.original_attn_processors is not None
): ):
assert check_qkv_fusion_processors_exist( assert check_qkv_fusion_processors_exist(component), (
component "Something wrong with the fused attention processors. Expected all the attention processors to be fused."
), "Something wrong with the fused attention processors. Expected all the attention processors to be fused." )
assert check_qkv_fusion_matches_attn_procs_length( assert check_qkv_fusion_matches_attn_procs_length(component, component.original_attn_processors), (
component, component.original_attn_processors "Something wrong with the attention processors concerning the fused QKV projections."
), "Something wrong with the attention processors concerning the fused QKV projections." )
inputs = self.get_dummy_inputs(device) inputs = self.get_dummy_inputs(device)
inputs["return_dict"] = False inputs["return_dict"] = False
...@@ -235,15 +235,15 @@ class SDFunctionTesterMixin: ...@@ -235,15 +235,15 @@ class SDFunctionTesterMixin:
image_disabled = pipe(**inputs)[0] image_disabled = pipe(**inputs)[0]
image_slice_disabled = image_disabled[0, -3:, -3:, -1] image_slice_disabled = image_disabled[0, -3:, -3:, -1]
assert np.allclose( assert np.allclose(original_image_slice, image_slice_fused, atol=1e-2, rtol=1e-2), (
original_image_slice, image_slice_fused, atol=1e-2, rtol=1e-2 "Fusion of QKV projections shouldn't affect the outputs."
), "Fusion of QKV projections shouldn't affect the outputs." )
assert np.allclose( assert np.allclose(image_slice_fused, image_slice_disabled, atol=1e-2, rtol=1e-2), (
image_slice_fused, image_slice_disabled, atol=1e-2, rtol=1e-2 "Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled."
), "Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled." )
assert np.allclose( assert np.allclose(original_image_slice, image_slice_disabled, atol=1e-2, rtol=1e-2), (
original_image_slice, image_slice_disabled, atol=1e-2, rtol=1e-2 "Original outputs should match when fused QKV projections are disabled."
), "Original outputs should match when fused QKV projections are disabled." )
class IPAdapterTesterMixin: class IPAdapterTesterMixin:
...@@ -909,9 +909,9 @@ class PipelineFromPipeTesterMixin: ...@@ -909,9 +909,9 @@ class PipelineFromPipeTesterMixin:
for component in pipe_original.components.values(): for component in pipe_original.components.values():
if hasattr(component, "attn_processors"): if hasattr(component, "attn_processors"):
assert all( assert all(type(proc) == AttnProcessor for proc in component.attn_processors.values()), (
type(proc) == AttnProcessor for proc in component.attn_processors.values() "`from_pipe` changed the attention processor in original pipeline."
), "`from_pipe` changed the attention processor in original pipeline." )
@require_accelerator @require_accelerator
@require_accelerate_version_greater("0.14.0") @require_accelerate_version_greater("0.14.0")
...@@ -2569,12 +2569,12 @@ class PyramidAttentionBroadcastTesterMixin: ...@@ -2569,12 +2569,12 @@ class PyramidAttentionBroadcastTesterMixin:
image_slice_pab_disabled = output.flatten() image_slice_pab_disabled = output.flatten()
image_slice_pab_disabled = np.concatenate((image_slice_pab_disabled[:8], image_slice_pab_disabled[-8:])) image_slice_pab_disabled = np.concatenate((image_slice_pab_disabled[:8], image_slice_pab_disabled[-8:]))
assert np.allclose( assert np.allclose(original_image_slice, image_slice_pab_enabled, atol=expected_atol), (
original_image_slice, image_slice_pab_enabled, atol=expected_atol "PAB outputs should not differ much in specified timestep range."
), "PAB outputs should not differ much in specified timestep range." )
assert np.allclose( assert np.allclose(original_image_slice, image_slice_pab_disabled, atol=1e-4), (
original_image_slice, image_slice_pab_disabled, atol=1e-4 "Outputs from normal inference and after disabling cache should not differ."
), "Outputs from normal inference and after disabling cache should not differ." )
class FasterCacheTesterMixin: class FasterCacheTesterMixin:
...@@ -2639,12 +2639,12 @@ class FasterCacheTesterMixin: ...@@ -2639,12 +2639,12 @@ class FasterCacheTesterMixin:
output = run_forward(pipe).flatten() output = run_forward(pipe).flatten()
image_slice_faster_cache_disabled = np.concatenate((output[:8], output[-8:])) image_slice_faster_cache_disabled = np.concatenate((output[:8], output[-8:]))
assert np.allclose( assert np.allclose(original_image_slice, image_slice_faster_cache_enabled, atol=expected_atol), (
original_image_slice, image_slice_faster_cache_enabled, atol=expected_atol "FasterCache outputs should not differ much in specified timestep range."
), "FasterCache outputs should not differ much in specified timestep range." )
assert np.allclose( assert np.allclose(original_image_slice, image_slice_faster_cache_disabled, atol=1e-4), (
original_image_slice, image_slice_faster_cache_disabled, atol=1e-4 "Outputs from normal inference and after disabling cache should not differ."
), "Outputs from normal inference and after disabling cache should not differ." )
def test_faster_cache_state(self): def test_faster_cache_state(self):
from diffusers.hooks.faster_cache import _FASTER_CACHE_BLOCK_HOOK, _FASTER_CACHE_DENOISER_HOOK from diffusers.hooks.faster_cache import _FASTER_CACHE_BLOCK_HOOK, _FASTER_CACHE_DENOISER_HOOK
......
...@@ -191,12 +191,12 @@ class WuerstchenCombinedPipelineFastTests(PipelineTesterMixin, unittest.TestCase ...@@ -191,12 +191,12 @@ class WuerstchenCombinedPipelineFastTests(PipelineTesterMixin, unittest.TestCase
expected_slice = np.array([0.7616304, 0.0, 1.0, 0.0, 1.0, 0.0, 0.05925313, 0.0, 0.951898]) expected_slice = np.array([0.7616304, 0.0, 1.0, 0.0, 1.0, 0.0, 0.05925313, 0.0, 0.951898])
assert ( assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2, (
np.abs(image_slice.flatten() - expected_slice).max() < 1e-2 f" expected_slice {expected_slice}, but got {image_slice.flatten()}"
), f" expected_slice {expected_slice}, but got {image_slice.flatten()}" )
assert ( assert np.abs(image_from_tuple_slice.flatten() - expected_slice).max() < 1e-2, (
np.abs(image_from_tuple_slice.flatten() - expected_slice).max() < 1e-2 f" expected_slice {expected_slice}, but got {image_from_tuple_slice.flatten()}"
), f" expected_slice {expected_slice}, but got {image_from_tuple_slice.flatten()}" )
@require_torch_accelerator @require_torch_accelerator
def test_offloads(self): def test_offloads(self):
......
...@@ -357,9 +357,9 @@ class DPMSolverMultistepSchedulerTest(SchedulerCommonTest): ...@@ -357,9 +357,9 @@ class DPMSolverMultistepSchedulerTest(SchedulerCommonTest):
prediction_type=prediction_type, prediction_type=prediction_type,
final_sigmas_type=final_sigmas_type, final_sigmas_type=final_sigmas_type,
) )
assert ( assert torch.sum(torch.abs(sample - sample_custom_timesteps)) < 1e-5, (
torch.sum(torch.abs(sample - sample_custom_timesteps)) < 1e-5 f"Scheduler outputs are not identical for algorithm_type: {algorithm_type}, prediction_type: {prediction_type} and final_sigmas_type: {final_sigmas_type}"
), f"Scheduler outputs are not identical for algorithm_type: {algorithm_type}, prediction_type: {prediction_type} and final_sigmas_type: {final_sigmas_type}" )
def test_beta_sigmas(self): def test_beta_sigmas(self):
self.check_over_configs(use_beta_sigmas=True) self.check_over_configs(use_beta_sigmas=True)
......
...@@ -345,9 +345,9 @@ class DPMSolverSinglestepSchedulerTest(SchedulerCommonTest): ...@@ -345,9 +345,9 @@ class DPMSolverSinglestepSchedulerTest(SchedulerCommonTest):
lower_order_final=lower_order_final, lower_order_final=lower_order_final,
final_sigmas_type=final_sigmas_type, final_sigmas_type=final_sigmas_type,
) )
assert ( assert torch.sum(torch.abs(sample - sample_custom_timesteps)) < 1e-5, (
torch.sum(torch.abs(sample - sample_custom_timesteps)) < 1e-5 f"Scheduler outputs are not identical for prediction_type: {prediction_type}, lower_order_final: {lower_order_final} and final_sigmas_type: {final_sigmas_type}"
), f"Scheduler outputs are not identical for prediction_type: {prediction_type}, lower_order_final: {lower_order_final} and final_sigmas_type: {final_sigmas_type}" )
def test_beta_sigmas(self): def test_beta_sigmas(self):
self.check_over_configs(use_beta_sigmas=True) self.check_over_configs(use_beta_sigmas=True)
......
...@@ -188,9 +188,9 @@ class EDMDPMSolverMultistepSchedulerTest(SchedulerCommonTest): ...@@ -188,9 +188,9 @@ class EDMDPMSolverMultistepSchedulerTest(SchedulerCommonTest):
prediction_type=prediction_type, prediction_type=prediction_type,
algorithm_type=algorithm_type, algorithm_type=algorithm_type,
) )
assert ( assert not torch.isnan(sample).any(), (
not torch.isnan(sample).any() f"Samples have nan numbers, {order}, {solver_type}, {prediction_type}, {algorithm_type}"
), f"Samples have nan numbers, {order}, {solver_type}, {prediction_type}, {algorithm_type}" )
def test_lower_order_final(self): def test_lower_order_final(self):
self.check_over_configs(lower_order_final=True) self.check_over_configs(lower_order_final=True)
......
...@@ -245,9 +245,9 @@ class EulerDiscreteSchedulerTest(SchedulerCommonTest): ...@@ -245,9 +245,9 @@ class EulerDiscreteSchedulerTest(SchedulerCommonTest):
interpolation_type=interpolation_type, interpolation_type=interpolation_type,
final_sigmas_type=final_sigmas_type, final_sigmas_type=final_sigmas_type,
) )
assert ( assert torch.sum(torch.abs(sample - sample_custom_timesteps)) < 1e-5, (
torch.sum(torch.abs(sample - sample_custom_timesteps)) < 1e-5 f"Scheduler outputs are not identical for prediction_type: {prediction_type}, interpolation_type: {interpolation_type} and final_sigmas_type: {final_sigmas_type}"
), f"Scheduler outputs are not identical for prediction_type: {prediction_type}, interpolation_type: {interpolation_type} and final_sigmas_type: {final_sigmas_type}" )
def test_custom_sigmas(self): def test_custom_sigmas(self):
for prediction_type in ["epsilon", "sample", "v_prediction"]: for prediction_type in ["epsilon", "sample", "v_prediction"]:
...@@ -260,9 +260,9 @@ class EulerDiscreteSchedulerTest(SchedulerCommonTest): ...@@ -260,9 +260,9 @@ class EulerDiscreteSchedulerTest(SchedulerCommonTest):
prediction_type=prediction_type, prediction_type=prediction_type,
final_sigmas_type=final_sigmas_type, final_sigmas_type=final_sigmas_type,
) )
assert ( assert torch.sum(torch.abs(sample - sample_custom_timesteps)) < 1e-5, (
torch.sum(torch.abs(sample - sample_custom_timesteps)) < 1e-5 f"Scheduler outputs are not identical for prediction_type: {prediction_type} and final_sigmas_type: {final_sigmas_type}"
), f"Scheduler outputs are not identical for prediction_type: {prediction_type} and final_sigmas_type: {final_sigmas_type}" )
def test_beta_sigmas(self): def test_beta_sigmas(self):
self.check_over_configs(use_beta_sigmas=True) self.check_over_configs(use_beta_sigmas=True)
......
...@@ -216,9 +216,9 @@ class HeunDiscreteSchedulerTest(SchedulerCommonTest): ...@@ -216,9 +216,9 @@ class HeunDiscreteSchedulerTest(SchedulerCommonTest):
prediction_type=prediction_type, prediction_type=prediction_type,
timestep_spacing=timestep_spacing, timestep_spacing=timestep_spacing,
) )
assert ( assert torch.sum(torch.abs(sample - sample_custom_timesteps)) < 1e-5, (
torch.sum(torch.abs(sample - sample_custom_timesteps)) < 1e-5 f"Scheduler outputs are not identical for prediction_type: {prediction_type}, timestep_spacing: {timestep_spacing}"
), f"Scheduler outputs are not identical for prediction_type: {prediction_type}, timestep_spacing: {timestep_spacing}" )
def test_beta_sigmas(self): def test_beta_sigmas(self):
self.check_over_configs(use_beta_sigmas=True) self.check_over_configs(use_beta_sigmas=True)
......
...@@ -72,9 +72,9 @@ class SDSingleFileTesterMixin: ...@@ -72,9 +72,9 @@ class SDSingleFileTesterMixin:
continue continue
assert component_name in pipe.components, f"single file {component_name} not found in pretrained pipeline" assert component_name in pipe.components, f"single file {component_name} not found in pretrained pipeline"
assert isinstance( assert isinstance(component, pipe.components[component_name].__class__), (
component, pipe.components[component_name].__class__ f"single file {component.__class__.__name__} and pretrained {pipe.components[component_name].__class__.__name__} are not the same"
), f"single file {component.__class__.__name__} and pretrained {pipe.components[component_name].__class__.__name__} are not the same" )
for param_name, param_value in component.config.items(): for param_name, param_value in component.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
...@@ -85,9 +85,9 @@ class SDSingleFileTesterMixin: ...@@ -85,9 +85,9 @@ class SDSingleFileTesterMixin:
if param_name == "upcast_attention" and pipe.components[component_name].config[param_name] is None: if param_name == "upcast_attention" and pipe.components[component_name].config[param_name] is None:
pipe.components[component_name].config[param_name] = param_value pipe.components[component_name].config[param_name] = param_value
assert ( assert pipe.components[component_name].config[param_name] == param_value, (
pipe.components[component_name].config[param_name] == param_value f"single file {param_name}: {param_value} differs from pretrained {pipe.components[component_name].config[param_name]}"
), f"single file {param_name}: {param_value} differs from pretrained {pipe.components[component_name].config[param_name]}" )
def test_single_file_components(self, pipe=None, single_file_pipe=None): def test_single_file_components(self, pipe=None, single_file_pipe=None):
single_file_pipe = single_file_pipe or self.pipeline_class.from_single_file( single_file_pipe = single_file_pipe or self.pipeline_class.from_single_file(
...@@ -253,9 +253,9 @@ class SDXLSingleFileTesterMixin: ...@@ -253,9 +253,9 @@ class SDXLSingleFileTesterMixin:
continue continue
assert component_name in pipe.components, f"single file {component_name} not found in pretrained pipeline" assert component_name in pipe.components, f"single file {component_name} not found in pretrained pipeline"
assert isinstance( assert isinstance(component, pipe.components[component_name].__class__), (
component, pipe.components[component_name].__class__ f"single file {component.__class__.__name__} and pretrained {pipe.components[component_name].__class__.__name__} are not the same"
), f"single file {component.__class__.__name__} and pretrained {pipe.components[component_name].__class__.__name__} are not the same" )
for param_name, param_value in component.config.items(): for param_name, param_value in component.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
...@@ -266,9 +266,9 @@ class SDXLSingleFileTesterMixin: ...@@ -266,9 +266,9 @@ class SDXLSingleFileTesterMixin:
if param_name == "upcast_attention" and pipe.components[component_name].config[param_name] is None: if param_name == "upcast_attention" and pipe.components[component_name].config[param_name] is None:
pipe.components[component_name].config[param_name] = param_value pipe.components[component_name].config[param_name] = param_value
assert ( assert pipe.components[component_name].config[param_name] == param_value, (
pipe.components[component_name].config[param_name] == param_value f"single file {param_name}: {param_value} differs from pretrained {pipe.components[component_name].config[param_name]}"
), f"single file {param_name}: {param_value} differs from pretrained {pipe.components[component_name].config[param_name]}" )
def test_single_file_components(self, pipe=None, single_file_pipe=None): def test_single_file_components(self, pipe=None, single_file_pipe=None):
single_file_pipe = single_file_pipe or self.pipeline_class.from_single_file( single_file_pipe = single_file_pipe or self.pipeline_class.from_single_file(
......
...@@ -60,9 +60,9 @@ class Lumina2Transformer2DModelSingleFileTests(unittest.TestCase): ...@@ -60,9 +60,9 @@ class Lumina2Transformer2DModelSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between single file loading and pretrained loading"
), f"{param_name} differs between single file loading and pretrained loading" )
def test_checkpoint_loading(self): def test_checkpoint_loading(self):
for ckpt_path in self.alternate_keys_ckpt_paths: for ckpt_path in self.alternate_keys_ckpt_paths:
......
...@@ -87,9 +87,9 @@ class AutoencoderDCSingleFileTests(unittest.TestCase): ...@@ -87,9 +87,9 @@ class AutoencoderDCSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between pretrained loading and single file loading"
), f"{param_name} differs between pretrained loading and single file loading" )
def test_single_file_in_type_variant_components(self): def test_single_file_in_type_variant_components(self):
# `in` variant checkpoints require passing in a `config` parameter # `in` variant checkpoints require passing in a `config` parameter
...@@ -106,9 +106,9 @@ class AutoencoderDCSingleFileTests(unittest.TestCase): ...@@ -106,9 +106,9 @@ class AutoencoderDCSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between pretrained loading and single file loading"
), f"{param_name} differs between pretrained loading and single file loading" )
def test_single_file_mix_type_variant_components(self): def test_single_file_mix_type_variant_components(self):
repo_id = "mit-han-lab/dc-ae-f128c512-mix-1.0-diffusers" repo_id = "mit-han-lab/dc-ae-f128c512-mix-1.0-diffusers"
...@@ -121,6 +121,6 @@ class AutoencoderDCSingleFileTests(unittest.TestCase): ...@@ -121,6 +121,6 @@ class AutoencoderDCSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between pretrained loading and single file loading"
), f"{param_name} differs between pretrained loading and single file loading" )
...@@ -58,9 +58,9 @@ class ControlNetModelSingleFileTests(unittest.TestCase): ...@@ -58,9 +58,9 @@ class ControlNetModelSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between single file loading and pretrained loading"
), f"{param_name} differs between single file loading and pretrained loading" )
def test_single_file_arguments(self): def test_single_file_arguments(self):
model_default = self.model_class.from_single_file(self.ckpt_path) model_default = self.model_class.from_single_file(self.ckpt_path)
......
...@@ -58,9 +58,9 @@ class FluxTransformer2DModelSingleFileTests(unittest.TestCase): ...@@ -58,9 +58,9 @@ class FluxTransformer2DModelSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between single file loading and pretrained loading"
), f"{param_name} differs between single file loading and pretrained loading" )
def test_checkpoint_loading(self): def test_checkpoint_loading(self):
for ckpt_path in self.alternate_keys_ckpt_paths: for ckpt_path in self.alternate_keys_ckpt_paths:
......
...@@ -40,9 +40,9 @@ class MotionAdapterSingleFileTests(unittest.TestCase): ...@@ -40,9 +40,9 @@ class MotionAdapterSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between pretrained loading and single file loading"
), f"{param_name} differs between pretrained loading and single file loading" )
def test_single_file_components_version_v1_5_2(self): def test_single_file_components_version_v1_5_2(self):
ckpt_path = "https://huggingface.co/guoyww/animatediff/blob/main/mm_sd_v15_v2.ckpt" ckpt_path = "https://huggingface.co/guoyww/animatediff/blob/main/mm_sd_v15_v2.ckpt"
...@@ -55,9 +55,9 @@ class MotionAdapterSingleFileTests(unittest.TestCase): ...@@ -55,9 +55,9 @@ class MotionAdapterSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between pretrained loading and single file loading"
), f"{param_name} differs between pretrained loading and single file loading" )
def test_single_file_components_version_v1_5_3(self): def test_single_file_components_version_v1_5_3(self):
ckpt_path = "https://huggingface.co/guoyww/animatediff/blob/main/v3_sd15_mm.ckpt" ckpt_path = "https://huggingface.co/guoyww/animatediff/blob/main/v3_sd15_mm.ckpt"
...@@ -70,9 +70,9 @@ class MotionAdapterSingleFileTests(unittest.TestCase): ...@@ -70,9 +70,9 @@ class MotionAdapterSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between pretrained loading and single file loading"
), f"{param_name} differs between pretrained loading and single file loading" )
def test_single_file_components_version_sdxl_beta(self): def test_single_file_components_version_sdxl_beta(self):
ckpt_path = "https://huggingface.co/guoyww/animatediff/blob/main/mm_sdxl_v10_beta.ckpt" ckpt_path = "https://huggingface.co/guoyww/animatediff/blob/main/mm_sdxl_v10_beta.ckpt"
...@@ -85,6 +85,6 @@ class MotionAdapterSingleFileTests(unittest.TestCase): ...@@ -85,6 +85,6 @@ class MotionAdapterSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between pretrained loading and single file loading"
), f"{param_name} differs between pretrained loading and single file loading" )
...@@ -60,9 +60,9 @@ class StableCascadeUNetSingleFileTest(unittest.TestCase): ...@@ -60,9 +60,9 @@ class StableCascadeUNetSingleFileTest(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between single file loading and pretrained loading"
), f"{param_name} differs between single file loading and pretrained loading" )
def test_single_file_components_stage_b_lite(self): def test_single_file_components_stage_b_lite(self):
model_single_file = StableCascadeUNet.from_single_file( model_single_file = StableCascadeUNet.from_single_file(
...@@ -77,9 +77,9 @@ class StableCascadeUNetSingleFileTest(unittest.TestCase): ...@@ -77,9 +77,9 @@ class StableCascadeUNetSingleFileTest(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between single file loading and pretrained loading"
), f"{param_name} differs between single file loading and pretrained loading" )
def test_single_file_components_stage_c(self): def test_single_file_components_stage_c(self):
model_single_file = StableCascadeUNet.from_single_file( model_single_file = StableCascadeUNet.from_single_file(
...@@ -94,9 +94,9 @@ class StableCascadeUNetSingleFileTest(unittest.TestCase): ...@@ -94,9 +94,9 @@ class StableCascadeUNetSingleFileTest(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between single file loading and pretrained loading"
), f"{param_name} differs between single file loading and pretrained loading" )
def test_single_file_components_stage_c_lite(self): def test_single_file_components_stage_c_lite(self):
model_single_file = StableCascadeUNet.from_single_file( model_single_file = StableCascadeUNet.from_single_file(
...@@ -111,6 +111,6 @@ class StableCascadeUNetSingleFileTest(unittest.TestCase): ...@@ -111,6 +111,6 @@ class StableCascadeUNetSingleFileTest(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between single file loading and pretrained loading"
), f"{param_name} differs between single file loading and pretrained loading" )
...@@ -91,9 +91,9 @@ class AutoencoderKLSingleFileTests(unittest.TestCase): ...@@ -91,9 +91,9 @@ class AutoencoderKLSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between pretrained loading and single file loading"
), f"{param_name} differs between pretrained loading and single file loading" )
def test_single_file_arguments(self): def test_single_file_arguments(self):
model_default = self.model_class.from_single_file(self.ckpt_path, config=self.repo_id) model_default = self.model_class.from_single_file(self.ckpt_path, config=self.repo_id)
......
...@@ -56,6 +56,6 @@ class AutoencoderKLWanSingleFileTests(unittest.TestCase): ...@@ -56,6 +56,6 @@ class AutoencoderKLWanSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between single file loading and pretrained loading"
), f"{param_name} differs between single file loading and pretrained loading" )
...@@ -57,9 +57,9 @@ class WanTransformer3DModelText2VideoSingleFileTest(unittest.TestCase): ...@@ -57,9 +57,9 @@ class WanTransformer3DModelText2VideoSingleFileTest(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between single file loading and pretrained loading"
), f"{param_name} differs between single file loading and pretrained loading" )
@require_big_gpu_with_torch_cuda @require_big_gpu_with_torch_cuda
...@@ -88,6 +88,6 @@ class WanTransformer3DModelImage2VideoSingleFileTest(unittest.TestCase): ...@@ -88,6 +88,6 @@ class WanTransformer3DModelImage2VideoSingleFileTest(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between single file loading and pretrained loading"
), f"{param_name} differs between single file loading and pretrained loading" )
...@@ -47,9 +47,9 @@ class SanaTransformer2DModelSingleFileTests(unittest.TestCase): ...@@ -47,9 +47,9 @@ class SanaTransformer2DModelSingleFileTests(unittest.TestCase):
for param_name, param_value in model_single_file.config.items(): for param_name, param_value in model_single_file.config.items():
if param_name in PARAMS_TO_IGNORE: if param_name in PARAMS_TO_IGNORE:
continue continue
assert ( assert model.config[param_name] == param_value, (
model.config[param_name] == param_value f"{param_name} differs between single file loading and pretrained loading"
), f"{param_name} differs between single file loading and pretrained loading" )
def test_checkpoint_loading(self): def test_checkpoint_loading(self):
for ckpt_path in self.alternate_keys_ckpt_paths: for ckpt_path in self.alternate_keys_ckpt_paths:
......
...@@ -35,7 +35,7 @@ def main(slack_channel_name=None): ...@@ -35,7 +35,7 @@ def main(slack_channel_name=None):
if line.get("nodeid", "") != "": if line.get("nodeid", "") != "":
test = line["nodeid"] test = line["nodeid"]
if line.get("duration", None) is not None: if line.get("duration", None) is not None:
duration = f'{line["duration"]:.4f}' duration = f"{line['duration']:.4f}"
if line.get("outcome", "") == "failed": if line.get("outcome", "") == "failed":
section_num_failed += 1 section_num_failed += 1
failed.append([test, duration, log.name.split("_")[0]]) failed.append([test, duration, log.name.split("_")[0]])
......
...@@ -104,8 +104,7 @@ def update_metadata(commit_sha: str): ...@@ -104,8 +104,7 @@ def update_metadata(commit_sha: str):
if commit_sha is not None: if commit_sha is not None:
commit_message = ( commit_message = (
f"Update with commit {commit_sha}\n\nSee: " f"Update with commit {commit_sha}\n\nSee: https://github.com/huggingface/diffusers/commit/{commit_sha}"
f"https://github.com/huggingface/diffusers/commit/{commit_sha}"
) )
else: else:
commit_message = "Update" commit_message = "Update"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment