Skip to content

Commit

Permalink
(SD) Fixes schedulers if recieving noise preds as numpy arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
monorimet committed Dec 4, 2023
1 parent d72da38 commit 35cac51
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ def step(

sigma_from = self.sigmas[self.step_index]
sigma_to = self.sigmas[self.step_index + 1]
noise_pred = (
torch.from_numpy(noise_pred)
if isinstance(noise_pred, np.ndarray)
else noise_pred
)
noise = randn_tensor(
torch.Size(noise_pred.shape),
dtype=torch.float16,
Expand Down
5 changes: 5 additions & 0 deletions apps/stable_diffusion/src/schedulers/shark_eulerdiscrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ def step(

sigma_hat = sigma * (gamma + 1)

noise_pred = (
torch.from_numpy(noise_pred)
if isinstance(noise_pred, np.ndarray)
else noise_pred
)
noise = randn_tensor(
noise_pred.shape,
dtype=noise_pred.dtype,
Expand Down
1 change: 1 addition & 0 deletions apps/stable_diffusion/src/utils/stencils/stencil_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def controlnet_hint_conversion(
controlnet_hint = hint_zoedepth(image)
case _:
return None
print(f"Controlnet hint is type {image.dtype}")
controlnet_hint = controlnet_hint_shaping(
controlnet_hint, height, width, dtype, num_images_per_prompt
)
Expand Down

0 comments on commit 35cac51

Please sign in to comment.