Update pipeline.py
Browse files- pipeline.py +5 -6
pipeline.py
CHANGED
@@ -561,16 +561,15 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
|
|
561 |
|
562 |
# scale the initial noise by the standard deviation required by the scheduler
|
563 |
latents = latents * self.scheduler.init_noise_sigma
|
564 |
-
|
565 |
-
# Apply motion and scale dynamics
|
566 |
for frame in range(num_frames):
|
567 |
-
x_offset = frame * x_velocity
|
568 |
-
y_offset = frame * y_velocity
|
569 |
scale_factor = 1 + frame * scale_velocity
|
570 |
|
571 |
# Apply offsets
|
572 |
-
latents[:, :, frame] = torch.roll(latents[:, :, frame], shifts=x_offset, dims=3) # x direction
|
573 |
-
latents[:, :, frame] = torch.roll(latents[:, :, frame], shifts=y_offset, dims=2) # y direction
|
574 |
|
575 |
# Apply scaling - This is a simple approach and might not be ideal for all applications
|
576 |
if scale_factor != 1:
|
|
|
561 |
|
562 |
# scale the initial noise by the standard deviation required by the scheduler
|
563 |
latents = latents * self.scheduler.init_noise_sigma
|
564 |
+
|
|
|
565 |
for frame in range(num_frames):
|
566 |
+
x_offset = int(frame * x_velocity) # Convert to int
|
567 |
+
y_offset = int(frame * y_velocity) # Convert to int
|
568 |
scale_factor = 1 + frame * scale_velocity
|
569 |
|
570 |
# Apply offsets
|
571 |
+
latents[:, :, frame] = torch.roll(latents[:, :, frame], shifts=(x_offset,), dims=3) # x direction
|
572 |
+
latents[:, :, frame] = torch.roll(latents[:, :, frame], shifts=(y_offset,), dims=2) # y direction
|
573 |
|
574 |
# Apply scaling - This is a simple approach and might not be ideal for all applications
|
575 |
if scale_factor != 1:
|