root commited on
Commit
788559b
·
1 Parent(s): 33feb37
Files changed (1) hide show
  1. handler.py +7 -9
handler.py CHANGED
@@ -328,12 +328,12 @@ class EndpointHandler():
328
  raise FileNotFoundError(f"The pose video was not found at: {pose_video_path}")
329
 
330
  # Speed up the pose video by 4x
331
- sped_up_pose_video_path = os.path.join(temp_dir, "sped_up_pose_video.mp4")
332
- self.speed_up_video(pose_video_path, sped_up_pose_video_path, factor=4)
333
 
334
  torch.manual_seed(seed)
335
- pose_images = read_frames(sped_up_pose_video_path)
336
- src_fps = get_fps(sped_up_pose_video_path)
337
 
338
  pose_list = []
339
  total_length = min(length, len(pose_images))
@@ -360,8 +360,6 @@ class EndpointHandler():
360
  cropped_face_path = os.path.join(save_dir, "cropped_face.jpg")
361
  cropped_face = self._crop_face(ref_image_no_bg, save_path=cropped_face_path)
362
 
363
- # Delete the pipeline and clear CUDA cache to free up memory
364
- del self.pipeline
365
  torch.cuda.empty_cache()
366
 
367
  # Perform face swapping
@@ -371,8 +369,8 @@ class EndpointHandler():
371
 
372
  # Slow down the produced video by 4x
373
  self.print_directory_contents(temp_dir)
374
- slowed_down_animation_path = os.path.join(save_dir, "slowed_down_animation_output.mp4")
375
- self.slow_down_video(animation_path, slowed_down_animation_path, factor=4)
376
 
377
  # Clear CUDA cache before RIFE interpolation
378
  torch.cuda.empty_cache()
@@ -380,7 +378,7 @@ class EndpointHandler():
380
  # Perform RIFE interpolation
381
  # self.print_directory_contents(temp_dir)
382
  rife_output_path = os.path.join(save_dir, "completed_result.mp4")
383
- self.run_rife_interpolation(slowed_down_animation_path, rife_output_path, multi=2, scale=0.5)
384
 
385
  # Encode the final video in base64
386
  with open(rife_output_path, "rb") as video_file:
 
328
  raise FileNotFoundError(f"The pose video was not found at: {pose_video_path}")
329
 
330
  # Speed up the pose video by 4x
331
+ # sped_up_pose_video_path = os.path.join(temp_dir, "sped_up_pose_video.mp4")
332
+ # self.speed_up_video(pose_video_path, sped_up_pose_video_path, factor=4)
333
 
334
  torch.manual_seed(seed)
335
+ pose_images = read_frames(pose_video_path)
336
+ src_fps = get_fps(pose_video_path)
337
 
338
  pose_list = []
339
  total_length = min(length, len(pose_images))
 
360
  cropped_face_path = os.path.join(save_dir, "cropped_face.jpg")
361
  cropped_face = self._crop_face(ref_image_no_bg, save_path=cropped_face_path)
362
 
 
 
363
  torch.cuda.empty_cache()
364
 
365
  # Perform face swapping
 
369
 
370
  # Slow down the produced video by 4x
371
  self.print_directory_contents(temp_dir)
372
+ # slowed_down_animation_path = os.path.join(save_dir, "slowed_down_animation_output.mp4")
373
+ # self.slow_down_video(animation_path, slowed_down_animation_path, factor=4)
374
 
375
  # Clear CUDA cache before RIFE interpolation
376
  torch.cuda.empty_cache()
 
378
  # Perform RIFE interpolation
379
  # self.print_directory_contents(temp_dir)
380
  rife_output_path = os.path.join(save_dir, "completed_result.mp4")
381
+ self.run_rife_interpolation(animation_path, rife_output_path, multi=2, scale=0.5)
382
 
383
  # Encode the final video in base64
384
  with open(rife_output_path, "rb") as video_file: