xmrt commited on
Commit
d151311
1 Parent(s): 1e4500f
Files changed (1) hide show
  1. main.py +79 -75
main.py CHANGED
@@ -92,8 +92,9 @@ def pose3d(video):
92
  rebase_keypoint_height=True,
93
  device="cuda")
94
 
 
 
95
  result = [result for result in result_generator] #next(result_generator)
96
- out_file = glob.glob(os.path.join(vis_out_dir, "*"))
97
  out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) + glob.glob(os.path.join(vis_out_dir, "*.webm"))
98
  print("[INFO]: CURRENT OUT FILE NAME: ", out_file)
99
 
@@ -108,10 +109,12 @@ def pose2d(video):
108
 
109
  result_generator = human(video,
110
  vis_out_dir = vis_out_dir,
111
- thickness=2,
112
  return_vis=True,
 
113
  rebase_keypoint_height=True,
114
- device="cuda")
 
 
115
 
116
  result = [result for result in result_generator] #next(result_generator)
117
 
@@ -145,78 +148,79 @@ def pose2dhand(video):
145
 
146
  return out_file
147
 
148
-
149
-
150
- with gr.Blocks() as demo:
151
- with gr.Column():
152
- with gr.Tab("Upload video"):
153
- with gr.Row():
154
- with gr.Column():
155
- video_input = gr.Video(source="upload", type="filepath", height=512)
156
- # Insert slider with kpt_thr
157
- file_kpthr = gr.Slider(0, 1, value=0.3)
158
-
159
- submit_pose_file = gr.Button("Make 2d pose estimation")
160
- submit_pose3d_file = gr.Button("Make 3d pose estimation")
161
- submit_hand_file = gr.Button("Make 2d hand estimation")
162
- submit_detect_file = gr.Button("Detect and track objects")
163
-
164
- video_output1 = gr.Video(height=512)
165
- video_output2 = gr.Video(height=512)
166
- video_output3 = gr.Video(height=512)
167
- video_output4 = gr.Video(height=512)
168
-
169
- with gr.Tab("Record video with webcam"):
170
- with gr.Row():
171
- with gr.Column():
172
- webcam_input = gr.Video(source="webcam", height=512)
173
-
174
- web_kpthr = gr.Slider(0, 1, value=0.3)
175
-
176
- submit_pose_web = gr.Button("Make 2d pose estimation")
177
- submit_pose3d_web = gr.Button("Make 3d pose estimation")
178
- submit_hand_web = gr.Button("Make 2d hand estimation")
179
- submit_detect_web = gr.Button("Detect and track objects")
180
-
181
- webcam_output1 = gr.Video(height=512)
182
- webcam_output2 = gr.Video(height=512)
183
- webcam_output3 = gr.Video(height=512)
184
- webcam_output4 = gr.Video(height=512)
185
-
 
 
186
 
187
-
188
- # From file
189
- submit_pose_file.click(fn=pose2d,
190
- inputs= video_input,
191
- outputs = video_output1)
192
-
193
- submit_pose3d_file.click(fn=pose3d,
194
- inputs= video_input,
195
- outputs = video_output2)
196
-
197
- submit_hand_file.click(fn=pose2dhand,
198
- inputs= video_input,
199
- outputs = video_output3)
200
-
201
- submit_detect_file.click(fn=show_tracking,
202
- inputs= video_input,
203
- outputs = video_output4)
204
-
205
- # Web
206
- submit_pose_web.click(fn=pose2d,
207
- inputs= webcam_input,
208
- outputs = webcam_output1)
209
-
210
- submit_pose3d_web.click(fn=pose3d,
211
- inputs= webcam_input,
212
- outputs = webcam_output2)
213
-
214
- submit_hand_web.click(fn=pose2dhand,
215
- inputs= webcam_input,
216
- outputs = video_output3)
217
-
218
- submit_detect_web.click(fn=show_tracking,
219
  inputs= webcam_input,
220
- outputs = video_output4)
 
 
 
 
221
 
222
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
92
  rebase_keypoint_height=True,
93
  device="cuda")
94
 
95
+ print("OUTDIR", os.listdir(os.path.join(vis_out_dir)))
96
+
97
  result = [result for result in result_generator] #next(result_generator)
 
98
  out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) + glob.glob(os.path.join(vis_out_dir, "*.webm"))
99
  print("[INFO]: CURRENT OUT FILE NAME: ", out_file)
100
 
 
109
 
110
  result_generator = human(video,
111
  vis_out_dir = vis_out_dir,
 
112
  return_vis=True,
113
+ thickness=2,
114
  rebase_keypoint_height=True,
115
+ #kpt_thr=kpt_thr,
116
+ device="cuda"
117
+ )
118
 
119
  result = [result for result in result_generator] #next(result_generator)
120
 
 
148
 
149
  return out_file
150
 
151
+ if __name__ == "__main__":
152
+
153
+
154
+ with gr.Blocks() as demo:
155
+ with gr.Column():
156
+ with gr.Tab("Upload video"):
157
+ with gr.Row():
158
+ with gr.Column():
159
+ video_input = gr.Video(source="upload", type="filepath", height=512)
160
+ # Insert slider with kpt_thr
161
+ file_kpthr = gr.Slider(0, 1, value=0.3)
162
+
163
+ submit_pose_file = gr.Button("Make 2d pose estimation")
164
+ submit_pose3d_file = gr.Button("Make 3d pose estimation")
165
+ submit_hand_file = gr.Button("Make 2d hand estimation")
166
+ submit_detect_file = gr.Button("Detect and track objects")
167
+
168
+ video_output1 = gr.Video(height=512)
169
+ video_output2 = gr.Video(height=512)
170
+ video_output3 = gr.Video(height=512)
171
+ video_output4 = gr.Video(height=512)
172
+
173
+ with gr.Tab("Record video with webcam"):
174
+ with gr.Row():
175
+ with gr.Column():
176
+ webcam_input = gr.Video(source="webcam", height=512)
177
+
178
+ web_kpthr = gr.Slider(0, 1, value=0.3)
179
+
180
+ submit_pose_web = gr.Button("Make 2d pose estimation")
181
+ submit_pose3d_web = gr.Button("Make 3d pose estimation")
182
+ submit_hand_web = gr.Button("Make 2d hand estimation")
183
+ submit_detect_web = gr.Button("Detect and track objects")
184
+
185
+ webcam_output1 = gr.Video(height=512)
186
+ webcam_output2 = gr.Video(height=512)
187
+ webcam_output3 = gr.Video(height=512)
188
+ webcam_output4 = gr.Video(height=512)
189
+
190
+
191
 
192
+ # From file
193
+ submit_pose_file.click(fn=pose2d,
194
+ inputs= video_input,
195
+ outputs = video_output1)
196
+
197
+ submit_pose3d_file.click(fn=pose3d,
198
+ inputs= video_input,
199
+ outputs = video_output2)
200
+
201
+ submit_hand_file.click(fn=pose2dhand,
202
+ inputs= video_input,
203
+ outputs = video_output3)
204
+
205
+ submit_detect_file.click(fn=show_tracking,
206
+ inputs= video_input,
207
+ outputs = video_output4)
208
+
209
+ # Web
210
+ submit_pose_web.click(fn=pose2d,
211
+ inputs = webcam_input,
212
+ outputs = webcam_output1)
213
+
214
+ submit_pose3d_web.click(fn=pose3d,
215
+ inputs= webcam_input,
216
+ outputs = webcam_output2)
217
+
218
+ submit_hand_web.click(fn=pose2dhand,
 
 
 
 
 
219
  inputs= webcam_input,
220
+ outputs = video_output3)
221
+
222
+ submit_detect_web.click(fn=show_tracking,
223
+ inputs= webcam_input,
224
+ outputs = video_output4)
225
 
226
+ demo.launch(server_name="0.0.0.0", server_port=7860)