smoothieAI commited on
Commit
14d3694
·
verified ·
1 Parent(s): f9e519c

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +10 -13
pipeline.py CHANGED
@@ -1496,17 +1496,6 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
1496
  start_guidance_time = time.time()
1497
 
1498
  if do_classifier_free_guidance:
1499
- # # Split tensor along its first dimension
1500
- # noise_pred_uncond, noise_pred_text = torch.chunk(noise_pred, 2, dim=0)
1501
-
1502
- # # Efficient in-place addition using advanced indexing
1503
- # noise_pred_uncond_sum[..., current_context_indexes, :, :] += noise_pred_uncond
1504
- # noise_pred_text_sum[..., current_context_indexes, :, :] += noise_pred_text
1505
-
1506
- # # Efficient in-place increment for latent_counter
1507
- # latent_counter[current_context_indexes] += 1
1508
-
1509
-
1510
  # Split tensor along its first dimension
1511
  noise_pred_uncond, noise_pred_text = torch.chunk(noise_pred, 2, dim=0)
1512
 
@@ -1518,10 +1507,18 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
1518
  # Perform batch addition
1519
  noise_pred_uncond_sum[..., current_context_indexes, :, :] += expanded_noise_pred_uncond
1520
  noise_pred_text_sum[..., current_context_indexes, :, :] += expanded_noise_pred_text
 
 
 
 
 
 
 
 
 
 
1521
 
1522
  # Batch increment for latent_counter
1523
- # Here, you need to ensure that the addition is done correctly depending on how latent_counter is structured
1524
- # If latent_counter is a tensor, you might use something like:
1525
  latent_counter[current_context_indexes] += 1
1526
 
1527
  print("guidance time", time.time() - start_guidance_time)
 
1496
  start_guidance_time = time.time()
1497
 
1498
  if do_classifier_free_guidance:
 
 
 
 
 
 
 
 
 
 
 
1499
  # Split tensor along its first dimension
1500
  noise_pred_uncond, noise_pred_text = torch.chunk(noise_pred, 2, dim=0)
1501
 
 
1507
  # Perform batch addition
1508
  noise_pred_uncond_sum[..., current_context_indexes, :, :] += expanded_noise_pred_uncond
1509
  noise_pred_text_sum[..., current_context_indexes, :, :] += expanded_noise_pred_text
1510
+
1511
+ # print devices and shapes for everything
1512
+ print("noise_pred_uncond_sum", noise_pred_uncond_sum.device, noise_pred_uncond_sum.shape)
1513
+ print("noise_pred_text_sum", noise_pred_text_sum.device, noise_pred_text_sum.shape)
1514
+ print("expanded_noise_pred_uncond", expanded_noise_pred_uncond.device, expanded_noise_pred_uncond.shape)
1515
+ print("expanded_noise_pred_text", expanded_noise_pred_text.device, expanded_noise_pred_text.shape)
1516
+ print("current_context_latents", current_context_latents.device, current_context_latents.shape)
1517
+ print("current_context_indexes", current_context_indexes.device, current_context_indexes.shape)
1518
+ print("latent_counter", latent_counter.device, latent_counter.shape)
1519
+
1520
 
1521
  # Batch increment for latent_counter
 
 
1522
  latent_counter[current_context_indexes] += 1
1523
 
1524
  print("guidance time", time.time() - start_guidance_time)