diff --git a/examples/community/pipeline_stg_hunyuan_video.py b/examples/community/pipeline_stg_hunyuan_video.py index e41f99e13a22..06c3acd5d107 100644 --- a/examples/community/pipeline_stg_hunyuan_video.py +++ b/examples/community/pipeline_stg_hunyuan_video.py @@ -189,11 +189,14 @@ def retrieve_timesteps( elif sigmas is not None: accept_sigmas = "sigmas" in set(inspect.signature(scheduler.set_timesteps).parameters.keys()) if not accept_sigmas: - raise ValueError( + logger.warning( f"The current scheduler class {scheduler.__class__}'s `set_timesteps` does not support custom" - f" sigmas schedules. Please check whether you are using the correct scheduler." + f" sigmas schedules. Please check whether you are using the correct scheduler. The pipeline" + f" will continue without setting sigma values" ) - scheduler.set_timesteps(sigmas=sigmas, device=device, **kwargs) + scheduler.set_timesteps(num_inference_steps=num_inference_steps, device=device, **kwargs) + else: + scheduler.set_timesteps(sigmas=sigmas, device=device, **kwargs) timesteps = scheduler.timesteps num_inference_steps = len(timesteps) else: @@ -723,9 +726,9 @@ def __call__( timestep = t.expand(latents.shape[0]).to(latents.dtype) if self.do_spatio_temporal_guidance: - for i in stg_applied_layers_idx: - self.transformer.transformer_blocks[i].forward = types.MethodType( - forward_without_stg, self.transformer.transformer_blocks[i] + for stg_idx in stg_applied_layers_idx: + self.transformer.transformer_blocks[stg_idx].forward = types.MethodType( + forward_without_stg, self.transformer.transformer_blocks[stg_idx] ) noise_pred = self.transformer( @@ -740,9 +743,9 @@ def __call__( )[0] if self.do_spatio_temporal_guidance: - for i in stg_applied_layers_idx: - self.transformer.transformer_blocks[i].forward = types.MethodType( - forward_with_stg, self.transformer.transformer_blocks[i] + for stg_idx in stg_applied_layers_idx: + self.transformer.transformer_blocks[stg_idx].forward = types.MethodType( + forward_with_stg, self.transformer.transformer_blocks[stg_idx] ) noise_pred_perturb = self.transformer( diff --git a/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_skyreels_image2video.py b/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_skyreels_image2video.py index 297d2a9c9396..7c2a958f8be6 100644 --- a/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_skyreels_image2video.py +++ b/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_skyreels_image2video.py @@ -139,11 +139,14 @@ def retrieve_timesteps( elif sigmas is not None: accept_sigmas = "sigmas" in set(inspect.signature(scheduler.set_timesteps).parameters.keys()) if not accept_sigmas: - raise ValueError( + logger.warning( f"The current scheduler class {scheduler.__class__}'s `set_timesteps` does not support custom" - f" sigmas schedules. Please check whether you are using the correct scheduler." + f" sigmas schedules. Please check whether you are using the correct scheduler. The pipeline" + f" will continue without setting sigma values" ) - scheduler.set_timesteps(sigmas=sigmas, device=device, **kwargs) + scheduler.set_timesteps(num_inference_steps, device=device) + else: + scheduler.set_timesteps(sigmas=sigmas, device=device, **kwargs) timesteps = scheduler.timesteps num_inference_steps = len(timesteps) else: diff --git a/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video.py b/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video.py index 3cb91b3782f2..68aa81ee8f3c 100644 --- a/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video.py +++ b/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video.py @@ -128,11 +128,14 @@ def retrieve_timesteps( elif sigmas is not None: accept_sigmas = "sigmas" in set(inspect.signature(scheduler.set_timesteps).parameters.keys()) if not accept_sigmas: - raise ValueError( + logger.warning( f"The current scheduler class {scheduler.__class__}'s `set_timesteps` does not support custom" - f" sigmas schedules. Please check whether you are using the correct scheduler." + f" sigmas schedules. Please check whether you are using the correct scheduler. The pipeline" + f" will continue without setting sigma values" ) - scheduler.set_timesteps(sigmas=sigmas, device=device, **kwargs) + scheduler.set_timesteps(num_inference_steps, device=device) + else: + scheduler.set_timesteps(sigmas=sigmas, device=device, **kwargs) timesteps = scheduler.timesteps num_inference_steps = len(timesteps) else: diff --git a/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video_image2video.py b/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video_image2video.py index 5a600dda4326..c3b1a8c25cd9 100644 --- a/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video_image2video.py +++ b/src/diffusers/pipelines/hunyuan_video/pipeline_hunyuan_video_image2video.py @@ -141,11 +141,14 @@ def retrieve_timesteps( elif sigmas is not None: accept_sigmas = "sigmas" in set(inspect.signature(scheduler.set_timesteps).parameters.keys()) if not accept_sigmas: - raise ValueError( + logger.warning( f"The current scheduler class {scheduler.__class__}'s `set_timesteps` does not support custom" - f" sigmas schedules. Please check whether you are using the correct scheduler." + f" sigmas schedules. Please check whether you are using the correct scheduler. The pipeline" + f" will continue without setting sigma values" ) - scheduler.set_timesteps(sigmas=sigmas, device=device, **kwargs) + scheduler.set_timesteps(num_inference_steps, device=device) + else: + scheduler.set_timesteps(sigmas=sigmas, device=device, **kwargs) timesteps = scheduler.timesteps num_inference_steps = len(timesteps) else: