smoothieAI commited on
Commit
af0c644
·
1 Parent(s): 737e734

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +9 -8
pipeline.py CHANGED
@@ -778,15 +778,16 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
778
  num_digits = output_path.count('#') # count the number of '#' characters
779
  frame_format = output_path.replace('#' * num_digits, '{:0' + str(num_digits) + 'd}')
780
 
781
- for start_idx in range(0, num_frames, output_batch_size):
782
- end_idx = min(start_idx + output_batch_size, num_frames)
783
- video_tensor = self.decode_latents(latents[:, :, start_idx:end_idx, :, :])
 
784
  video = tensor2vid(video_tensor, self.image_processor, output_type=output_type)
785
-
786
- for batch_idx, frame_batch in enumerate(video[0][0]):
787
- for frame_idx, frame in enumerate(frame_batch):
788
- frame_number = start_idx + batch_idx * len(frame_batch[0][0]) + frame_idx
789
- frame.save(frame_format.format(frame_number))
790
  return output_path
791
 
792
  # Post-processing
 
778
  num_digits = output_path.count('#') # count the number of '#' characters
779
  frame_format = output_path.replace('#' * num_digits, '{:0' + str(num_digits) + 'd}')
780
 
781
+ for batch in range((num_frames + output_batch_size - 1) // output_batch_size):
782
+ start_id = batch * output_batch_size
783
+ end_id = min((batch + 1) * output_batch_size, num_frames)
784
+ video_tensor = self.decode_latents(latents[:, :, start_id:end_id, :, :])
785
  video = tensor2vid(video_tensor, self.image_processor, output_type=output_type)
786
+ frame_list = video[0][0]
787
+ print("frame_list type", type(frame_list))
788
+ for f_id, frame in enumerate(frame_list):
789
+ frame_number = start_id + f_id
790
+ frame.save(frame_format.format(frame_number))
791
  return output_path
792
 
793
  # Post-processing