xmrt commited on
Commit
c186703
1 Parent(s): 879a6e4

make directory

Browse files
Files changed (1) hide show
  1. main.py +36 -40
main.py CHANGED
@@ -82,15 +82,18 @@ def show_tracking(video_content):
82
 
83
 
84
  def pose3d(video):
 
 
 
 
 
 
 
 
85
  add_dir = str(uuid.uuid4())
86
- #vidname = video.split("/")[-1]
87
  vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
88
- print("[INFO]: CURRENT OUT DIR: ", vis_out_dir)
89
- print("[INFO]: LIST CURRENT OUT DIR: ", os.listdir("/".join(video.split("/")[:-1])))
90
  os.makedirs(vis_out_dir)
91
 
92
- #full name = os.path.join(vis_out_dir, vidname)
93
-
94
  result_generator = human3d(video,
95
  vis_out_dir = vis_out_dir,
96
  thickness=2,
@@ -98,30 +101,26 @@ def pose3d(video):
98
  rebase_keypoint_height=True,
99
  device="cuda")
100
 
101
- print("OUTDIR", os.listdir(os.path.join(vis_out_dir)))
102
-
103
- result = [result for result in result_generator] #next(result_generator)
104
- out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) + glob.glob(os.path.join(vis_out_dir, "*.webm"))
105
- print("[INFO]: CURRENT OUT FILE NAME: ", out_file)
106
 
107
- return out_file
 
 
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())
120
  vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
121
  os.makedirs(vis_out_dir)
122
- print("[INFO]: CURRENT OUT DIR: ", vis_out_dir)
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,
@@ -133,26 +132,25 @@ def pose2d(video):
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 "".join(out_file)
144
 
145
 
146
  def pose2dhand(video):
 
 
 
 
 
 
 
 
147
  add_dir = str(uuid.uuid4())
148
  vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
149
  os.makedirs(vis_out_dir)
150
 
151
- print("[INFO]: CURRENT OUT DIR: ", vis_out_dir)
152
- print("[INFO]: LIST CURRENT OUT DIR: ", os.listdir("/".join(video.split("/")[:-1])))
153
-
154
- vis_out_dir = str(uuid.uuid4())
155
-
156
  result_generator = hand(video,
157
  vis_out_dir = vis_out_dir,
158
  return_vis=True,
@@ -160,13 +158,11 @@ def pose2dhand(video):
160
  rebase_keypoint_height=True,
161
  device="cuda")
162
 
163
- result = [result for result in result_generator] #next(result_generator)
164
-
165
- print(glob.glob(os.path.join(vis_out_dir, "*.mp4")) + glob.glob(os.path.join(vis_out_dir, "*.webm")))
166
-
167
- out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) + glob.glob(os.path.join(vis_out_dir, "*.webm"))
168
-
169
- return out_file
170
 
171
  def run_UI():
172
  with gr.Blocks() as demo:
@@ -174,7 +170,7 @@ def run_UI():
174
  with gr.Tab("Upload video"):
175
  with gr.Row():
176
  with gr.Column():
177
- video_input = gr.Video(source="upload", type="filepath", height=512)
178
  # Insert slider with kpt_thr
179
  file_kpthr = gr.Slider(minimum=1e3, maximum=1e6, step=1e3, default=1e3, label='Keypoint threshold')
180
 
@@ -191,7 +187,7 @@ def run_UI():
191
  with gr.Tab("Record video with webcam"):
192
  with gr.Row():
193
  with gr.Column():
194
- webcam_input = gr.Video(source="webcam", height=512)
195
 
196
  web_kpthr = gr.Slider(minimum=1e3, maximum=1e6, step=1e3, default=1e3, label='Keypoint threshold')
197
 
 
82
 
83
 
84
  def pose3d(video):
85
+ if video[:-5] == ".webm":
86
+ print("Format is webm, changing it to mp4...")
87
+ clip = moviepy.VideoFileClip(video)
88
+
89
+ new_video = video[:-5]+".mp4"
90
+ clip.write_videofile(new_video)
91
+
92
+ # Define new unique folder
93
  add_dir = str(uuid.uuid4())
 
94
  vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
 
 
95
  os.makedirs(vis_out_dir)
96
 
 
 
97
  result_generator = human3d(video,
98
  vis_out_dir = vis_out_dir,
99
  thickness=2,
 
101
  rebase_keypoint_height=True,
102
  device="cuda")
103
 
104
+ result = [result for result in result_generator] #next(result_generator)
 
 
 
 
105
 
106
+ out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) #+ glob.glob(os.path.join(vis_out_dir, "*.webm"))
107
+
108
+ return "".join(out_file)
109
 
110
 
111
  def pose2d(video):
 
 
112
 
113
+ if video[:-5] == ".webm":
114
+ print("Format is webm, changing it to mp4...")
115
+ clip = moviepy.VideoFileClip(video)
116
+
117
+ new_video = video[:-5]+".mp4"
118
+ clip.write_videofile(new_video)
119
 
120
+ # Define new unique folder
 
121
  add_dir = str(uuid.uuid4())
122
  vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
123
  os.makedirs(vis_out_dir)
 
 
 
124
 
125
  result_generator = human(new_video,
126
  vis_out_dir = vis_out_dir,
 
132
  )
133
 
134
  result = [result for result in result_generator] #next(result_generator)
 
 
 
 
 
 
135
 
136
+ out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) #+ glob.glob(os.path.join(vis_out_dir, "*.webm"))
137
+
138
  return "".join(out_file)
139
 
140
 
141
  def pose2dhand(video):
142
+ if video[:-5] == ".webm":
143
+ print("Format is webm, changing it to mp4...")
144
+ clip = moviepy.VideoFileClip(video)
145
+
146
+ new_video = video[:-5]+".mp4"
147
+ clip.write_videofile(new_video)
148
+
149
+ # Define new unique folder
150
  add_dir = str(uuid.uuid4())
151
  vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
152
  os.makedirs(vis_out_dir)
153
 
 
 
 
 
 
154
  result_generator = hand(video,
155
  vis_out_dir = vis_out_dir,
156
  return_vis=True,
 
158
  rebase_keypoint_height=True,
159
  device="cuda")
160
 
161
+ result = [result for result in result_generator] #next(result_generator)
162
+
163
+ out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) #+ glob.glob(os.path.join(vis_out_dir, "*.webm"))
164
+
165
+ return "".join(out_file)
 
 
166
 
167
  def run_UI():
168
  with gr.Blocks() as demo:
 
170
  with gr.Tab("Upload video"):
171
  with gr.Row():
172
  with gr.Column():
173
+ video_input = gr.Video(source="upload", type="filepath", height=612)
174
  # Insert slider with kpt_thr
175
  file_kpthr = gr.Slider(minimum=1e3, maximum=1e6, step=1e3, default=1e3, label='Keypoint threshold')
176
 
 
187
  with gr.Tab("Record video with webcam"):
188
  with gr.Row():
189
  with gr.Column():
190
+ webcam_input = gr.Video(source="webcam", height=612)
191
 
192
  web_kpthr = gr.Slider(minimum=1e3, maximum=1e6, step=1e3, default=1e3, label='Keypoint threshold')
193