root commited on
Commit
3a724c5
·
1 Parent(s): 70fbc25

creating pose from video

Browse files
__pycache__/handler.cpython-310.pyc CHANGED
Binary files a/__pycache__/handler.cpython-310.pyc and b/__pycache__/handler.cpython-310.pyc differ
 
dw_poses_videos/pose-3.mp4 DELETED
Binary file (692 kB)
 
handler.py CHANGED
@@ -273,7 +273,7 @@ class EndpointHandler():
273
  video_url = inputs.get("video_url", "")
274
  width = inputs.get("width", 512)
275
  height = inputs.get("height", 768)
276
- length = inputs.get("length", 96)
277
  num_inference_steps = inputs.get("num_inference_steps", 25)
278
  cfg = inputs.get("cfg", 3.5)
279
  seed = inputs.get("seed", 123)
@@ -340,9 +340,9 @@ class EndpointHandler():
340
 
341
  torch.manual_seed(seed)
342
 
343
- temporary_pose_video_path = os.path.join(base_dir, 'dancing.mp4')
344
- pose_images = read_frames(temporary_pose_video_path)
345
- src_fps = get_fps(temporary_pose_video_path)
346
 
347
  pose_list = []
348
  total_length = min(length, len(pose_images))
@@ -394,13 +394,13 @@ class EndpointHandler():
394
 
395
  #remove background
396
  # self.print_directory_contents()
397
- removed_background_output_path = os.path.join(save_dir, "removed_background_result.mp4")
398
- remove_background_script_path = os.path.join(base_dir, "rembg_video.py")
399
- remove_background_command = f'python3 {remove_background_script_path} {swapped_face_video_path} {removed_background_output_path}'
400
- print("Command is " + remove_background_command)
401
- remove_background_result = subprocess.run(remove_background_command, shell=True, capture_output=True, text=True)
402
- if remove_background_result.returncode != 0:
403
- raise RuntimeError(f"Error running removing backgriund: {remove_background_result.stderr}")
404
 
405
 
406
  # Perform RIFE interpolation
@@ -409,7 +409,7 @@ class EndpointHandler():
409
  # self.run_rife_interpolation(swapped_face_video_path, rife_output_path, multi=2, scale=0.5)
410
 
411
  # Encode the final video in base64
412
- with open(removed_background_output_path, "rb") as video_file:
413
  video_base64 = base64.b64encode(video_file.read()).decode("utf-8")
414
 
415
  torch.cuda.empty_cache()
 
273
  video_url = inputs.get("video_url", "")
274
  width = inputs.get("width", 512)
275
  height = inputs.get("height", 768)
276
+ length = inputs.get("length", 144)
277
  num_inference_steps = inputs.get("num_inference_steps", 25)
278
  cfg = inputs.get("cfg", 3.5)
279
  seed = inputs.get("seed", 123)
 
340
 
341
  torch.manual_seed(seed)
342
 
343
+ # temporary_pose_video_path = os.path.join(base_dir, 'dancing.mp4')
344
+ pose_images = read_frames(downloaded_video_path)
345
+ src_fps = get_fps(downloaded_video_path)
346
 
347
  pose_list = []
348
  total_length = min(length, len(pose_images))
 
394
 
395
  #remove background
396
  # self.print_directory_contents()
397
+ # removed_background_output_path = os.path.join(save_dir, "removed_background_result.mp4")
398
+ # remove_background_script_path = os.path.join(base_dir, "rembg_video.py")
399
+ # remove_background_command = f'python3 {remove_background_script_path} {swapped_face_video_path} {removed_background_output_path}'
400
+ # print("Command is " + remove_background_command)
401
+ # remove_background_result = subprocess.run(remove_background_command, shell=True, capture_output=True, text=True)
402
+ # if remove_background_result.returncode != 0:
403
+ # raise RuntimeError(f"Error running removing backgriund: {remove_background_result.stderr}")
404
 
405
 
406
  # Perform RIFE interpolation
 
409
  # self.run_rife_interpolation(swapped_face_video_path, rife_output_path, multi=2, scale=0.5)
410
 
411
  # Encode the final video in base64
412
+ with open(swapped_face_video_path, "rb") as video_file:
413
  video_base64 = base64.b64encode(video_file.read()).decode("utf-8")
414
 
415
  torch.cuda.empty_cache()
sampler.py CHANGED
@@ -22,9 +22,9 @@ handler = EndpointHandler()
22
  # Define sample inputs
23
  inputs = {
24
  "inputs": {
25
- "ref_image_url": "https://media.discordapp.net/attachments/1237667104866697267/1246982998520496261/image.jpg?ex=665e5eea&is=665d0d6a&hm=46a719438e039655788336902d62419a2921a00720b21ac17e74755cb6de8cee&=&format=webp&width=976&height=1192",
26
- "video_url": "https://cdn.discordapp.com/attachments/1237667104866697267/1246950669689290752/pose.mp4?ex=665e40ce&is=665cef4e&hm=37a5f042a2d03f71c4ae5e9f56616a35d205b97df0ff205182cab28aa7784bbb&",
27
- "length": 12,
28
  "num_inference_steps": 25,
29
  "cfg": 3.5,
30
  "seed": 123
 
22
  # Define sample inputs
23
  inputs = {
24
  "inputs": {
25
+ "ref_image_url": "https://media.discordapp.net/attachments/1237667074210267217/1247311431028703242/image.png?ex=665f90cb&is=665e3f4b&hm=89767149275a6ef40e39d4a73d77019ab30ab665512398816bc614cfecdddb34&=&format=webp&quality=lossless&width=590&height=1194",
26
+ "video_url": "https://firebasestorage.googleapis.com/v0/b/quiz-app-edffe.appspot.com/o/creeper_shortneed_pose.mp4?alt=media&token=f87f6e8c-6ab2-445c-8b55-205f08f1f5d5",
27
+ "length": 96,
28
  "num_inference_steps": 25,
29
  "cfg": 3.5,
30
  "seed": 123