Skip to content

Commit

Permalink
Fixed exception whensigma is already a Tensor object and not numpy ar…
Browse files Browse the repository at this point in the history
…ray. Conditional check for tensor, if yes, just assign it or else cast the numpy array to tensor
  • Loading branch information
Kokane committed Dec 5, 2023
1 parent f427345 commit e50cecf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/diffusers/schedulers/scheduling_euler_discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ 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)
sigmas = (
torch.from_numpy(sigmas).to(dtype=torch.float32, device=device)
if not isinstance(sigmas, torch.Tensor)
else sigmas
)

# 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":
Expand Down

0 comments on commit e50cecf

Please sign in to comment.