smoothieAI commited on
Commit
7c97e9b
·
1 Parent(s): 100f28e

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +3 -11
pipeline.py CHANGED
@@ -775,24 +775,16 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
775
 
776
  # save frames
777
  if output_path is not None:
778
- output_batch_size = 2# prevents out of memory errors with large videos
779
- num_frames = latents.size(2) # latents' shape is [batch, channels, frames, height, width]
780
  num_digits = output_path.count('#') # count the number of '#' characters
781
  frame_format = output_path.replace('#' * num_digits, '{:0' + str(num_digits) + 'd}')
782
-
783
  for batch in range((num_frames + output_batch_size - 1) // output_batch_size):
784
  start_id = batch * output_batch_size
785
  end_id = min((batch + 1) * output_batch_size, num_frames)
786
  video_tensor = self.decode_latents(latents[:, :, start_id:end_id, :, :])
787
  video = tensor2vid(video_tensor, self.image_processor, output_type=output_type)
788
- frame_list = video[0]
789
- for f_id, frame in enumerate(frame_list):
790
- # print frame and batch id
791
- print(f"Frame: {f_id + start_id} Batch: {batch}")
792
- frame_number = start_id + f_id
793
- output_file = frame_format.format(frame_number)
794
- print(f"Saving to: {output_file}")
795
- frame.save(frame_format.format(frame_number))
796
  return output_path
797
 
798
  # Post-processing
 
775
 
776
  # save frames
777
  if output_path is not None:
778
+ output_batch_size = 2 # prevents out of memory errors with large videos
 
779
  num_digits = output_path.count('#') # count the number of '#' characters
780
  frame_format = output_path.replace('#' * num_digits, '{:0' + str(num_digits) + 'd}')
 
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
+ for f_id, frame in enumerate(video[0]):
787
+ frame.save(frame_format.format(start_id + f_id))
 
 
 
 
 
 
788
  return output_path
789
 
790
  # Post-processing