From a628f166ddd7fb4cd5146d0136ef23d52edc533a Mon Sep 17 00:00:00 2001 From: Thushit Kumar R <101030274+Senume@users.noreply.github.com> Date: Tue, 5 Dec 2023 14:28:29 +0530 Subject: [PATCH] Update scheduling_euler_discrete.py Type Error fix. During the type conversion, it expects for NumPy array, which fails when tensor array is passed. Sol: Check the type before conversion. --- src/diffusers/schedulers/scheduling_euler_discrete.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/diffusers/schedulers/scheduling_euler_discrete.py b/src/diffusers/schedulers/scheduling_euler_discrete.py index 53dc2ae15432..4e1b75845715 100644 --- a/src/diffusers/schedulers/scheduling_euler_discrete.py +++ b/src/diffusers/schedulers/scheduling_euler_discrete.py @@ -280,7 +280,12 @@ def set_timesteps(self, num_inference_steps: int, device: Union[str, torch.devic sigmas = self._convert_to_karras(in_sigmas=sigmas, num_inference_steps=self.num_inference_steps) timesteps = np.array([self._sigma_to_t(sigma, log_sigmas) for sigma in sigmas]) - sigmas = torch.from_numpy(sigmas).to(dtype=torch.float32, device=device) + # Checking 'sigmas' type before datatype conversion + if isinstance(sigmas, np.ndarray) + sigmas = torch.from_numpy(sigmas).to(dtype=torch.float32, device=device) + else: + sigmas = sigmas.to(dtype=torch.float32, device=device) + # TODO: Support the full EDM scalings for all prediction types and timestep types if self.config.timestep_type == "continuous" and self.config.prediction_type == "v_prediction":