xmrt commited on
Commit
4ce546f
1 Parent(s): 7c1031f

make directory

Browse files
Files changed (2) hide show
  1. main.py +21 -15
  2. requirements.txt +2 -1
main.py CHANGED
@@ -10,6 +10,8 @@ import torch
10
 
11
  # Gradio
12
  import gradio as gr
 
 
13
 
14
  # System and files
15
  import os
@@ -106,6 +108,12 @@ def pose3d(video):
106
 
107
 
108
  def pose2d(video):
 
 
 
 
 
 
109
  vidname = video.split("/")[-1]
110
  print("VIDNAME", vidname)
111
  add_dir = str(uuid.uuid4())
@@ -115,23 +123,22 @@ def pose2d(video):
115
  print("[INFO]: LIST CURRENT OUT DIR: ", os.listdir("/".join(video.split("/")[:-1])))
116
 
117
 
118
- result_generator = human(video,
119
- vis_out_dir = add_dir,
120
- return_vis=True,
121
- thickness=2,
122
- rebase_keypoint_height=True,
123
- #kpt_thr=kpt_thr,
124
- device="cuda"
125
- )
126
 
127
  result = [result for result in result_generator] #next(result_generator)
128
- print(result)
129
-
130
 
131
- out_file = glob.glob(os.path.join(add_dir, "*.mp4")) + glob.glob(os.path.join(add_dir, "*.webm"))
132
  #out_file = os.path.join(vis_out_dir, "sample_flip.webm")
133
  print("OTFILE: ", out_file)
134
- print("ADD DIR ", os.listdir(add_dir))
135
 
136
  return out_file
137
 
@@ -171,7 +178,7 @@ if __name__ == "__main__":
171
  with gr.Column():
172
  video_input = gr.Video(source="upload", type="filepath", height=512)
173
  # Insert slider with kpt_thr
174
- file_kpthr = gr.Slider(0, 1, value=1, label="Keypoint threshold",step=5, info='1')
175
 
176
  submit_pose_file = gr.Button("Make 2d pose estimation")
177
  submit_pose3d_file = gr.Button("Make 3d pose estimation")
@@ -188,8 +195,7 @@ if __name__ == "__main__":
188
  with gr.Column():
189
  webcam_input = gr.Video(source="webcam", height=512)
190
 
191
- web_kpthr = gr.Slider(0, 1, value=1, label="Keypoint threshold",step=5, info='1')
192
-
193
 
194
  submit_pose_web = gr.Button("Make 2d pose estimation")
195
  submit_pose3d_web = gr.Button("Make 3d pose estimation")
 
10
 
11
  # Gradio
12
  import gradio as gr
13
+ import moviepy.editor as moviepy
14
+
15
 
16
  # System and files
17
  import os
 
108
 
109
 
110
  def pose2d(video):
111
+ print("Transforming input")
112
+ clip = moviepy.VideoFileClip(video)
113
+
114
+ new_video = video[:-5]+".mp4"
115
+ clip.write_videofile(new_video)
116
+
117
  vidname = video.split("/")[-1]
118
  print("VIDNAME", vidname)
119
  add_dir = str(uuid.uuid4())
 
123
  print("[INFO]: LIST CURRENT OUT DIR: ", os.listdir("/".join(video.split("/")[:-1])))
124
 
125
 
126
+ result_generator = human(new_video,
127
+ vis_out_dir = vis_out_dir,
128
+ return_vis=True,
129
+ thickness=2,
130
+ rebase_keypoint_height=True,
131
+ #kpt_thr=kpt_thr,
132
+ device="cuda"
133
+ )
134
 
135
  result = [result for result in result_generator] #next(result_generator)
136
+ #print(result)
 
137
 
138
+ out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) + glob.glob(os.path.join(vis_out_dir, "*.webm"))
139
  #out_file = os.path.join(vis_out_dir, "sample_flip.webm")
140
  print("OTFILE: ", out_file)
141
+ print("ADD DIR ", os.listdir(vis_out_dir))
142
 
143
  return out_file
144
 
 
178
  with gr.Column():
179
  video_input = gr.Video(source="upload", type="filepath", height=512)
180
  # Insert slider with kpt_thr
181
+ file_kpthr = gr.Slider(minimum=1e3, maximum=1e6, step=1e3, default=1e3, label='Keypoint threshold')
182
 
183
  submit_pose_file = gr.Button("Make 2d pose estimation")
184
  submit_pose3d_file = gr.Button("Make 3d pose estimation")
 
195
  with gr.Column():
196
  webcam_input = gr.Video(source="webcam", height=512)
197
 
198
+ web_kpthr = gr.Slider(minimum=1e3, maximum=1e6, step=1e3, default=1e3, label='Keypoint threshold')
 
199
 
200
  submit_pose_web = gr.Button("Make 2d pose estimation")
201
  submit_pose3d_web = gr.Button("Make 3d pose estimation")
requirements.txt CHANGED
@@ -3,4 +3,5 @@ numpy
3
  opencv-python
4
  ultralytics
5
  lap
6
- torchvision
 
 
3
  opencv-python
4
  ultralytics
5
  lap
6
+ torchvision
7
+ MoviePy