Update pipeline.py
Browse files- pipeline.py +5 -4
pipeline.py
CHANGED
@@ -541,7 +541,7 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
|
|
541 |
latents = latents * self.scheduler.init_noise_sigma
|
542 |
return latents
|
543 |
|
544 |
-
def prepare_latents_same_start(self, batch_size, num_channels_latents, num_frames, height, width, dtype, device, generator, latents=None, context_size=16,
|
545 |
shape = (
|
546 |
batch_size,
|
547 |
num_channels_latents,
|
@@ -560,12 +560,13 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
|
|
560 |
else:
|
561 |
latents = latents.to(device)
|
562 |
|
563 |
-
# make every (context_size-
|
564 |
-
loop_size = context_size -
|
565 |
loop_count = num_frames // loop_size
|
566 |
for i in range(loop_count):
|
567 |
# repeat the first frames noise for i*loop_size frame
|
568 |
-
|
|
|
569 |
|
570 |
# scale the initial noise by the standard deviation required by the scheduler
|
571 |
latents = latents * self.scheduler.init_noise_sigma
|
|
|
541 |
latents = latents * self.scheduler.init_noise_sigma
|
542 |
return latents
|
543 |
|
544 |
+
def prepare_latents_same_start(self, batch_size, num_channels_latents, num_frames, height, width, dtype, device, generator, latents=None, context_size=16, overlap=4, strength=0.5):
|
545 |
shape = (
|
546 |
batch_size,
|
547 |
num_channels_latents,
|
|
|
560 |
else:
|
561 |
latents = latents.to(device)
|
562 |
|
563 |
+
# make every (context_size-overlap) frames have the same noise
|
564 |
+
loop_size = context_size - overlap
|
565 |
loop_count = num_frames // loop_size
|
566 |
for i in range(loop_count):
|
567 |
# repeat the first frames noise for i*loop_size frame
|
568 |
+
# lerp the first frames noise
|
569 |
+
latents[:, :, i*loop_size:(i*loop_size)+overlap, :, :] = torch.lerp(latents[:, :, i*loop_size:(i*loop_size)+overlap, :, :], latents[:, :, 0:overlap, :, :], strength)
|
570 |
|
571 |
# scale the initial noise by the standard deviation required by the scheduler
|
572 |
latents = latents * self.scheduler.init_noise_sigma
|