Yzy00518 commited on
Commit
2de58f8
·
verified ·
1 Parent(s): 55790c5

Update src/app/render.py

Browse files
Files changed (1) hide show
  1. src/app/render.py +8 -11
src/app/render.py CHANGED
@@ -19,7 +19,7 @@ def get_smplx_model(bs, deivce):
19
  return smpl_model.eval()
20
 
21
 
22
- def render_motion_to_video(motion, device, output_path, title, step=2):
23
  length = motion['transl'].shape[0]
24
  model = get_smplx_model(length, device)
25
  vertices = model(
@@ -61,20 +61,11 @@ def render_motion_to_video(motion, device, output_path, title, step=2):
61
 
62
  img_path = os.path.join(temp_dir, f"frame_{i:04d}.png")
63
  cv2.imwrite(img_path, image)
64
-
65
- # font = cv2.FONT_HERSHEY_SIMPLEX
66
- # font_scale = 1.0
67
- # font_color = (0, 55, 0) # 白色
68
- # font_thickness = 2
69
- # text_size = cv2.getTextSize(title, font, font_scale, font_thickness)[0]
70
- # text_x = (image.shape[1] - text_size[0]) // 2 # 水平居中
71
- # text_y = image.shape[0] - 30 # 底部上方30像素
72
- # cv2.putText(image, title, (text_x, text_y), font, font_scale, font_color, font_thickness)
73
  images.append(image)
74
 
75
  if images:
76
  height, width, _ = images[0].shape
77
- sampled_fps = 20 / step
78
  temp_video_path = output_path.replace('.mp4', '_temp.mp4')
79
 
80
  fourcc = cv2.VideoWriter_fourcc(*'mp4v')
@@ -112,8 +103,12 @@ def render_motion_to_video(motion, device, output_path, title, step=2):
112
 
113
 
114
  from argparse import ArgumentParser
 
115
  if __name__ == "__main__":
116
  parser = ArgumentParser()
 
 
 
117
  parser.add_argument("--motion_path", type=str, required=True)
118
  parser.add_argument("--title", type=str, default="rendered_motion.mp4")
119
 
@@ -125,3 +120,5 @@ if __name__ == "__main__":
125
 
126
  print(args.title)
127
  render_motion_to_video(motion, device, output_path, args.title)
 
 
 
19
  return smpl_model.eval()
20
 
21
 
22
+ def render_motion_to_video(motion, device, output_path, title, step=3):
23
  length = motion['transl'].shape[0]
24
  model = get_smplx_model(length, device)
25
  vertices = model(
 
61
 
62
  img_path = os.path.join(temp_dir, f"frame_{i:04d}.png")
63
  cv2.imwrite(img_path, image)
 
 
 
 
 
 
 
 
 
64
  images.append(image)
65
 
66
  if images:
67
  height, width, _ = images[0].shape
68
+ sampled_fps = int((20+step/2) / step)
69
  temp_video_path = output_path.replace('.mp4', '_temp.mp4')
70
 
71
  fourcc = cv2.VideoWriter_fourcc(*'mp4v')
 
103
 
104
 
105
  from argparse import ArgumentParser
106
+ import time
107
  if __name__ == "__main__":
108
  parser = ArgumentParser()
109
+ print('******Start rendering...******')
110
+ start_time = time.time()
111
+
112
  parser.add_argument("--motion_path", type=str, required=True)
113
  parser.add_argument("--title", type=str, default="rendered_motion.mp4")
114
 
 
120
 
121
  print(args.title)
122
  render_motion_to_video(motion, device, output_path, args.title)
123
+
124
+ print(f"******Rendering finished in {time.time() - start_time:.2f} seconds.******")