Update pipeline.py
Browse files- pipeline.py +19 -5
pipeline.py
CHANGED
@@ -1498,14 +1498,28 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
|
|
1498 |
|
1499 |
# sum the noise predictions for the unconditional and text conditioned noise
|
1500 |
start_guidance_time = time.time()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1501 |
if do_classifier_free_guidance:
|
1502 |
-
|
|
|
1503 |
|
1504 |
-
#
|
1505 |
-
noise_pred_uncond_sum[
|
1506 |
-
noise_pred_text_sum[
|
1507 |
-
|
|
|
1508 |
latent_counter[current_context_indexes] += 1
|
|
|
1509 |
print("guidance time", time.time() - start_guidance_time)
|
1510 |
|
1511 |
# set the step index to the current batch
|
|
|
1498 |
|
1499 |
# sum the noise predictions for the unconditional and text conditioned noise
|
1500 |
start_guidance_time = time.time()
|
1501 |
+
|
1502 |
+
# if do_classifier_free_guidance:
|
1503 |
+
# noise_pred_uncond, noise_pred_text = noise_pred.chunk(2)
|
1504 |
+
|
1505 |
+
# # add the ending frames from noise_pred_uncond to the start of the noise_pred_uncond_sum
|
1506 |
+
# noise_pred_uncond_sum[:, :,current_context_indexes, :, :] += noise_pred_uncond
|
1507 |
+
# noise_pred_text_sum[:, :,current_context_indexes, :, :] += noise_pred_text
|
1508 |
+
# #increase the counter for the ending frames
|
1509 |
+
# latent_counter[current_context_indexes] += 1
|
1510 |
+
|
1511 |
+
|
1512 |
if do_classifier_free_guidance:
|
1513 |
+
# Split tensor along its first dimension
|
1514 |
+
noise_pred_uncond, noise_pred_text = torch.chunk(noise_pred, 2, dim=0)
|
1515 |
|
1516 |
+
# Efficient in-place addition using advanced indexing
|
1517 |
+
noise_pred_uncond_sum[..., current_context_indexes, :, :] += noise_pred_uncond
|
1518 |
+
noise_pred_text_sum[..., current_context_indexes, :, :] += noise_pred_text
|
1519 |
+
|
1520 |
+
# Efficient in-place increment for latent_counter
|
1521 |
latent_counter[current_context_indexes] += 1
|
1522 |
+
|
1523 |
print("guidance time", time.time() - start_guidance_time)
|
1524 |
|
1525 |
# set the step index to the current batch
|