Adjust the x0 of some DFEs
This commit is contained in:
1 parent
e8573dad34
commit
d5612dd35c
1 file changed
+16
-1
@@ -537,7 +537,18 @@ class DiffusionFeatureExtractor4(nn.Module):
|
|||||||
if model is not None and hasattr(model, 'get_stepped_pred'):
|
if model is not None and hasattr(model, 'get_stepped_pred'):
|
||||||
stepped_latents = model.get_stepped_pred(noise_pred, noise)
|
stepped_latents = model.get_stepped_pred(noise_pred, noise)
|
||||||
else:
|
else:
|
||||||
stepped_latents = self.step_latents(noise, noise_pred, noisy_latents, timesteps, scheduler)
|
with torch.no_grad():
|
||||||
|
tv = timesteps.to(noise_pred.device).to(noise_pred.dtype) / 1000.0
|
||||||
|
# expand shape to match noise_pred
|
||||||
|
while len(tv.shape) < len(noise_pred.shape):
|
||||||
|
tv = tv.unsqueeze(-1)
|
||||||
|
# min 0.001
|
||||||
|
tv = torch.clamp(tv, min=0.001)
|
||||||
|
|
||||||
|
# step latent
|
||||||
|
x0 = noisy_latents - tv * noise_pred
|
||||||
|
|
||||||
|
stepped_latents = x0
|
||||||
|
|
||||||
latents = stepped_latents.to(self.vae.device, dtype=self.vae.dtype)
|
latents = stepped_latents.to(self.vae.device, dtype=self.vae.dtype)
|
||||||
|
|
||||||
@@ -684,6 +695,10 @@ class DiffusionFeatureExtractor6(nn.Module):
|
|||||||
if not torch.is_floating_point(x):
|
if not torch.is_floating_point(x):
|
||||||
x = x.float()
|
x = x.float()
|
||||||
|
|
||||||
|
# VAE decode can overshoot [0, 1] slightly; clamp so the rescale
|
||||||
|
# heuristic below never mistakes an overshoot for 0..255 input
|
||||||
|
x = torch.clamp(x, 0.0, 1.0)
|
||||||
|
|
||||||
# Resize
|
# Resize
|
||||||
# if not divisible by 16 or total pixels > max_res*max_res, resize to fit within 16 patches
|
# if not divisible by 16 or total pixels > max_res*max_res, resize to fit within 16 patches
|
||||||
max_res = 512
|
max_res = 512
|
||||||
|
|||||||
Reference in new issue
Block a user