Skip to content

Commit

Permalink
Fix ddim + inpainting not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Jun 26, 2023
1 parent 4eab00e commit c71a7e6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion comfy/ldm/models/diffusion/ddim.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ def sample(self,
)
return samples, intermediates

def q_sample(self, x_start, t, noise=None):
if noise is None:
noise = torch.randn_like(x_start)
return (extract_into_tensor(self.sqrt_alphas_cumprod, t, x_start.shape) * x_start +
extract_into_tensor(self.sqrt_one_minus_alphas_cumprod, t, x_start.shape) * noise)

@torch.no_grad()
def ddim_sampling(self, cond, shape,
x_T=None, ddim_use_original_steps=False,
Expand Down Expand Up @@ -214,7 +220,7 @@ def ddim_sampling(self, cond, shape,

if mask is not None:
assert x0 is not None
img_orig = self.model.q_sample(x0, ts) # TODO: deterministic forward pass?
img_orig = self.q_sample(x0, ts) # TODO: deterministic forward pass?
img = img_orig * mask + (1. - mask) * img

if ucg_schedule is not None:
Expand Down

0 comments on commit c71a7e6

Please sign in to comment.