xmrt commited on
Commit
21e50d2
1 Parent(s): 897d384
Files changed (2) hide show
  1. main.py +17 -14
  2. main_noweb.py +3 -3
main.py CHANGED
@@ -106,17 +106,18 @@ def show_tracking(video_content):
106
 
107
 
108
  def pose3d(video):
 
109
  video = check_extension(video)
110
  print(device)
111
 
112
 
113
  # Define new unique folder
114
  add_dir = str(uuid.uuid4())
115
- vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
116
- os.makedirs(vis_out_dir)
117
 
118
  result_generator = human3d(video,
119
- vis_out_dir = vis_out_dir,
120
  thickness=4,
121
  radius = 5,
122
  return_vis=True,
@@ -126,7 +127,7 @@ def pose3d(video):
126
 
127
  result = [result for result in result_generator] #next(result_generator)
128
 
129
- out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) #+ glob.glob(os.path.join(vis_out_dir, "*.webm"))
130
 
131
  # Reinitialize
132
  human3d().init()
@@ -134,29 +135,31 @@ def pose3d(video):
134
 
135
 
136
  def pose2d(video, kpt_threshold):
 
 
137
  video = check_extension(video)
138
  print(device)
139
 
140
  # Define new unique folder
141
  add_dir = str(uuid.uuid4())
142
- vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
143
- os.makedirs(vis_out_dir)
144
 
145
  result_generator = human(video,
146
- vis_out_dir = vis_out_dir,
147
  return_vis=True,
148
  radius = 5,
149
  thickness=4,
150
  rebase_keypoint_height=True,
151
  kpt_thr=kpt_threshold,
152
  device=device,
153
- pred_out_dir = vis_out_dir
154
  )
155
 
156
  result = [result for result in result_generator] #next(result_generator)
157
 
158
- out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) #+ glob.glob(os.path.join(vis_out_dir, "*.webm"))
159
- kpoints = glob.glob(os.path.join(vis_out_dir, "*.json"))
160
 
161
  return "".join(out_file), "".join(kpoints)
162
 
@@ -168,11 +171,11 @@ def pose2dhand(video, kpt_threshold):
168
 
169
  # Define new unique folder
170
  add_dir = str(uuid.uuid4())
171
- vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
172
- os.makedirs(vis_out_dir)
173
 
174
  result_generator = hand(video,
175
- vis_out_dir = vis_out_dir,
176
  return_vis=True,
177
  thickness = 4,
178
  radius = 5,
@@ -182,7 +185,7 @@ def pose2dhand(video, kpt_threshold):
182
 
183
  result = [result for result in result_generator] #next(result_generator)
184
 
185
- out_file = glob.glob(os.path.join(vis_out_dir, "*.mp4")) #+ glob.glob(os.path.join(vis_out_dir, "*.webm"))
186
 
187
  return "".join(out_file)
188
 
 
106
 
107
 
108
  def pose3d(video):
109
+
110
  video = check_extension(video)
111
  print(device)
112
 
113
 
114
  # Define new unique folder
115
  add_dir = str(uuid.uuid4())
116
+ #vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
117
+ os.makedirs(add_dir)
118
 
119
  result_generator = human3d(video,
120
+ vis_out_dir = add_dir,
121
  thickness=4,
122
  radius = 5,
123
  return_vis=True,
 
127
 
128
  result = [result for result in result_generator] #next(result_generator)
129
 
130
+ out_file = glob.glob(os.path.join(add_dir, "*.mp4")) #+ glob.glob(os.path.join(vis_out_dir, "*.webm"))
131
 
132
  # Reinitialize
133
  human3d().init()
 
135
 
136
 
137
  def pose2d(video, kpt_threshold):
138
+ human = MMPoseInferencer("human")
139
+
140
  video = check_extension(video)
141
  print(device)
142
 
143
  # Define new unique folder
144
  add_dir = str(uuid.uuid4())
145
+ #vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
146
+ os.makedirs(add_dir)
147
 
148
  result_generator = human(video,
149
+ vis_out_dir = add_dir,
150
  return_vis=True,
151
  radius = 5,
152
  thickness=4,
153
  rebase_keypoint_height=True,
154
  kpt_thr=kpt_threshold,
155
  device=device,
156
+ pred_out_dir = add_dir
157
  )
158
 
159
  result = [result for result in result_generator] #next(result_generator)
160
 
161
+ out_file = glob.glob(os.path.join(add_dir, "*.mp4")) #+ glob.glob(os.path.join(vis_out_dir, "*.webm"))
162
+ kpoints = glob.glob(os.path.join(add_dir, "*.json"))
163
 
164
  return "".join(out_file), "".join(kpoints)
165
 
 
171
 
172
  # Define new unique folder
173
  add_dir = str(uuid.uuid4())
174
+ #vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
175
+ os.makedirs(add_dir)
176
 
177
  result_generator = hand(video,
178
+ vis_out_dir = add_dir,
179
  return_vis=True,
180
  thickness = 4,
181
  radius = 5,
 
185
 
186
  result = [result for result in result_generator] #next(result_generator)
187
 
188
+ out_file = glob.glob(os.path.join(add_dir, "*.mp4")) #+ glob.glob(os.path.join(vis_out_dir, "*.webm"))
189
 
190
  return "".join(out_file)
191
 
main_noweb.py CHANGED
@@ -35,7 +35,6 @@ hand = MMPoseInferencer("hand")
35
  human3d = MMPoseInferencer(pose3d="human3d")
36
  track_model = YOLO('yolov8n.pt') # Load an official Detect model
37
 
38
-
39
  print("[INFO]: Downloaded models!")
40
 
41
  def check_extension(video):
@@ -139,7 +138,7 @@ def pose2d(video, kpt_threshold):
139
  # Define new unique folder
140
  add_dir = str(uuid.uuid4())
141
  vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
142
-
143
  os.makedirs(add_dir)
144
 
145
  result_generator = human(video,
@@ -265,7 +264,8 @@ with block:
265
  queue=False)
266
 
267
  if __name__ == "__main__":
268
- block.queue(concurrency_count=10, # When you increase the concurrency_count parameter in queue(), max_threads() in launch() is automatically increased as well.
 
269
  max_size=25, # Maximum number of requests that the queue processes
270
  api_open = False # When creating a Gradio demo, you may want to restrict all traffic to happen through the user interface as opposed to the programmatic API that is automatically created for your Gradio demo.
271
  ) # https://www.gradio.app/guides/setting-up-a-demo-for-maximum-performance
 
35
  human3d = MMPoseInferencer(pose3d="human3d")
36
  track_model = YOLO('yolov8n.pt') # Load an official Detect model
37
 
 
38
  print("[INFO]: Downloaded models!")
39
 
40
  def check_extension(video):
 
138
  # Define new unique folder
139
  add_dir = str(uuid.uuid4())
140
  vis_out_dir = os.path.join("/".join(video.split("/")[:-1]), add_dir)
141
+
142
  os.makedirs(add_dir)
143
 
144
  result_generator = human(video,
 
264
  queue=False)
265
 
266
  if __name__ == "__main__":
267
+ block.queue(share=True,
268
+ concurrency_count=10, # When you increase the concurrency_count parameter in queue(), max_threads() in launch() is automatically increased as well.
269
  max_size=25, # Maximum number of requests that the queue processes
270
  api_open = False # When creating a Gradio demo, you may want to restrict all traffic to happen through the user interface as opposed to the programmatic API that is automatically created for your Gradio demo.
271
  ) # https://www.gradio.app/guides/setting-up-a-demo-for-maximum-performance