-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify FlowMatch Scale Noise #8678
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,7 +129,31 @@ def scale_noise( | |
if self.step_index is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can also remove this here Let's remove it and run the example for img2img to see if the results match from |
||
self._init_step_index(timestep) | ||
|
||
sigma = self.sigmas[self.step_index] | ||
# Make sure sigmas and timesteps have the same device and dtype as original_samples | ||
sigmas = self.sigmas.to(device=sample.device, dtype=sample.dtype) | ||
asomoza marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the difference comes from casting simgas dtype There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, IMO is not worse, probably if I didn't use an example with a single fruit against a black background, I wouldn’t have even noticed the difference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok let's merge then :) |
||
|
||
if sample.device.type == "mps" and torch.is_floating_point(timestep): | ||
# mps does not support float64 | ||
schedule_timesteps = self.timesteps.to(sample.device, dtype=torch.float32) | ||
timestep = timestep.to(sample.device, dtype=torch.float32) | ||
else: | ||
schedule_timesteps = self.timesteps.to(sample.device) | ||
timestep = timestep.to(sample.device) | ||
|
||
# self.begin_index is None when scheduler is used for training, or pipeline does not implement set_begin_index | ||
if self.begin_index is None: | ||
step_indices = [self.index_for_timestep(t, schedule_timesteps) for t in timestep] | ||
elif self.step_index is not None: | ||
# add_noise is called after first denoising step (for inpainting) | ||
step_indices = [self.step_index] * timestep.shape[0] | ||
else: | ||
# add noise is called before first denoising step to create initial latent(img2img) | ||
step_indices = [self.begin_index] * timestep.shape[0] | ||
|
||
sigma = sigmas[step_indices].flatten() | ||
while len(sigma.shape) < len(sample.shape): | ||
sigma = sigma.unsqueeze(-1) | ||
|
||
sample = sigma * noise + (1.0 - sigma) * sample | ||
|
||
return sample | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱😱😱😱
thanks for the fix!