xmrt commited on
Commit
a4769fb
1 Parent(s): b3bc76f
Files changed (1) hide show
  1. main.py +18 -15
main.py CHANGED
@@ -147,14 +147,16 @@ def pose2d(video, kpt_threshold):
147
  thickness=4,
148
  rebase_keypoint_height=True,
149
  kpt_thr=kpt_threshold,
150
- device=device
 
151
  )
152
 
153
  result = [result for result in result_generator] #next(result_generator)
154
 
155
  out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) #+ glob.glob(os.path.join(vis_out_dir, "*.webm"))
156
-
157
- return "".join(out_file)
 
158
 
159
 
160
  def pose2dhand(video, kpt_threshold):
@@ -192,18 +194,19 @@ with block:
192
  video_input = gr.Video(source="upload", type="filepath", height=612)
193
  # Insert slider with kpt_thr
194
  file_kpthr = gr.Slider(0, 1, value=0.3, label='Keypoint threshold')
195
-
196
- submit_pose_file = gr.Button("Make 2d pose estimation", variant="primary")
197
- submit_pose3d_file = gr.Button("Make 3d pose estimation", variant="primary")
198
- submit_hand_file = gr.Button("Make 2d hand estimation", variant="primary")
199
- submit_detect_file = gr.Button("Detect and track objects", variant="primary")
200
 
201
  with gr.Row():
202
  video_output1 = gr.PlayableVideo(height=512, label = "Estimate human 2d poses", show_label=True)
203
  video_output2 = gr.PlayableVideo(height=512, label = "Estimate human 3d poses", show_label=True)
204
  video_output3 = gr.PlayableVideo(height=512, label = "Estimate human hand poses", show_label=True)
205
  video_output4 = gr.Video(height=512, label = "Detection and tracking", show_label=True, format="mp4")
206
-
 
207
  with gr.Tab("Record video with webcam"):
208
 
209
  with gr.Column():
@@ -212,11 +215,11 @@ with block:
212
  webcam_input = gr.Video(source="webcam", height=612)
213
 
214
  web_kpthr = gr.Slider(0, 1, value=0.3, label='Keypoint threshold')
215
-
216
- submit_pose_web = gr.Button("Make 2d pose estimation", variant="primary")
217
- submit_pose3d_web = gr.Button("Make 3d pose estimation", variant="primary")
218
- submit_hand_web = gr.Button("Make 2d hand estimation", variant="primary")
219
- submit_detect_web = gr.Button("Detect and track objects", variant="primary")
220
  with gr.Row():
221
  webcam_output1 = gr.PlayableVideo(height=716, label = "Estimate human 2d poses", show_label=True)
222
  webcam_output2 = gr.PlayableVideo(height=716, label = "Estimate human 3d poses", show_label=True)
@@ -259,7 +262,7 @@ with block:
259
  # From file
260
  submit_pose_file.click(fn=pose2d,
261
  inputs= [video_input, file_kpthr],
262
- outputs = video_output1,
263
  queue=False)
264
 
265
  submit_pose3d_file.click(fn=pose3d,
 
147
  thickness=4,
148
  rebase_keypoint_height=True,
149
  kpt_thr=kpt_threshold,
150
+ device=device,
151
+ pred_out_dir = vis_out_dir
152
  )
153
 
154
  result = [result for result in result_generator] #next(result_generator)
155
 
156
  out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) #+ glob.glob(os.path.join(vis_out_dir, "*.webm"))
157
+ kpoints = glob.glob(os.path.join(vis_out_dir, "*.json"))
158
+
159
+ return "".join(out_file), kpoints
160
 
161
 
162
  def pose2dhand(video, kpt_threshold):
 
194
  video_input = gr.Video(source="upload", type="filepath", height=612)
195
  # Insert slider with kpt_thr
196
  file_kpthr = gr.Slider(0, 1, value=0.3, label='Keypoint threshold')
197
+ with gr.Row():
198
+ submit_pose_file = gr.Button("Make 2d pose estimation", variant="primary")
199
+ submit_pose3d_file = gr.Button("Make 3d pose estimation", variant="primary")
200
+ submit_hand_file = gr.Button("Make 2d hand estimation", variant="primary")
201
+ submit_detect_file = gr.Button("Detect and track objects", variant="primary")
202
 
203
  with gr.Row():
204
  video_output1 = gr.PlayableVideo(height=512, label = "Estimate human 2d poses", show_label=True)
205
  video_output2 = gr.PlayableVideo(height=512, label = "Estimate human 3d poses", show_label=True)
206
  video_output3 = gr.PlayableVideo(height=512, label = "Estimate human hand poses", show_label=True)
207
  video_output4 = gr.Video(height=512, label = "Detection and tracking", show_label=True, format="mp4")
208
+ jsonoutput = gr.Code("json")
209
+
210
  with gr.Tab("Record video with webcam"):
211
 
212
  with gr.Column():
 
215
  webcam_input = gr.Video(source="webcam", height=612)
216
 
217
  web_kpthr = gr.Slider(0, 1, value=0.3, label='Keypoint threshold')
218
+ with gr.Row():
219
+ submit_pose_web = gr.Button("Make 2d pose estimation", variant="primary")
220
+ submit_pose3d_web = gr.Button("Make 3d pose estimation", variant="primary")
221
+ submit_hand_web = gr.Button("Make 2d hand estimation", variant="primary")
222
+ submit_detect_web = gr.Button("Detect and track objects", variant="primary")
223
  with gr.Row():
224
  webcam_output1 = gr.PlayableVideo(height=716, label = "Estimate human 2d poses", show_label=True)
225
  webcam_output2 = gr.PlayableVideo(height=716, label = "Estimate human 3d poses", show_label=True)
 
262
  # From file
263
  submit_pose_file.click(fn=pose2d,
264
  inputs= [video_input, file_kpthr],
265
+ outputs = [video_output1, jsonoutput],
266
  queue=False)
267
 
268
  submit_pose3d_file.click(fn=pose3d,