xmrt commited on
Commit
0e929df
1 Parent(s): 602fda1
Files changed (1) hide show
  1. main.py +14 -4
main.py CHANGED
@@ -7,8 +7,12 @@ import numpy as np
7
  import cv2
8
 
9
  print("[INFO]: Imported modules!")
 
 
 
 
 
10
 
11
- inferencer = MMPoseInferencer('hand') # 'hand', 'human , device='cuda'
12
  # inferencer = MMPoseInferencer('human')
13
  # inferencer = MMPoseInferencer(pose3d="human3d")
14
 
@@ -25,7 +29,10 @@ inferencer = MMPoseInferencer('hand') # 'hand', 'human , device='cuda'
25
  print("[INFO]: Downloaded models!")
26
 
27
 
28
- def poses(photo):
 
 
 
29
  print("[INFO]: Running inference!")
30
  #vis_out_dir
31
  result_generator = inferencer(photo,
@@ -80,9 +87,11 @@ def poses(photo):
80
 
81
  def run():
82
  #https://github.com/open-mmlab/mmpose/blob/main/docs/en/user_guides/inference.md
 
 
83
  webcam = gr.Interface(
84
  fn=poses,
85
- inputs= gr.Video(source="webcam"),
86
  outputs = gr.Video(format='mp4'),
87
  title = 'Pose estimation',
88
  description = 'Pose estimation on video',
@@ -91,10 +100,11 @@ def run():
91
 
92
  file = gr.Interface(
93
  poses,
94
- inputs = gr.Video(source="upload"),
95
  outputs = gr.Video(format='mp4'),
96
  allow_flagging=False
97
  )
 
98
  demo = gr.TabbedInterface(
99
  interface_list=[file, webcam],
100
  tab_names=["From a File", "From your Webcam"]
 
7
  import cv2
8
 
9
  print("[INFO]: Imported modules!")
10
+ human = MMPoseInferencer("human")
11
+ hand = MMPoseInferencer("hand")
12
+ human3d = MMPoseInferencer(pose3d="human3d")
13
+
14
+ inferencers = {"Estimate human 2d poses":human, "Estimate human 2d hand poses":hand, "Estimate human 3d poses":human3d}
15
 
 
16
  # inferencer = MMPoseInferencer('human')
17
  # inferencer = MMPoseInferencer(pose3d="human3d")
18
 
 
29
  print("[INFO]: Downloaded models!")
30
 
31
 
32
+ def poses(photo, check):
33
+ # Selecting the specific inferencer
34
+ inferencer = inferencers[check] # 'hand', 'human , device='cuda'
35
+
36
  print("[INFO]: Running inference!")
37
  #vis_out_dir
38
  result_generator = inferencer(photo,
 
87
 
88
  def run():
89
  #https://github.com/open-mmlab/mmpose/blob/main/docs/en/user_guides/inference.md
90
+ available_methods = ["Estimate human 2d poses", "Estimate human 2d hand poses", "Estimate human 3d poses"]
91
+ check = gr.CheckboxGroup(available_methods, label="Methods", type="value", info="Select the model(s) you want")
92
  webcam = gr.Interface(
93
  fn=poses,
94
+ inputs= [gr.Video(source="webcam"), check],
95
  outputs = gr.Video(format='mp4'),
96
  title = 'Pose estimation',
97
  description = 'Pose estimation on video',
 
100
 
101
  file = gr.Interface(
102
  poses,
103
+ inputs = [gr.Video(source="upload"), check],
104
  outputs = gr.Video(format='mp4'),
105
  allow_flagging=False
106
  )
107
+
108
  demo = gr.TabbedInterface(
109
  interface_list=[file, webcam],
110
  tab_names=["From a File", "From your Webcam"]