themalinery commited on
Commit
dc5cbbb
·
1 Parent(s): 7c70ded

removed hand pose estimation

Browse files
Files changed (1) hide show
  1. app.py +18 -41
app.py CHANGED
@@ -6,13 +6,8 @@ import tempfile
6
  import yaml
7
  from src.utils import (
8
  create_video_from_images,
9
- process_hand_pose_estimation,
10
  process_body_pose_estimation,
11
  )
12
- from src.mediapipe_pose.get_landmarks_and_connections import (
13
- get_default_hand_landmark_style,
14
- get_default_hand_connection_style,
15
- )
16
 
17
 
18
  def hex_to_bgr(color_input):
@@ -54,18 +49,16 @@ def hex_to_bgr(color_input):
54
 
55
  def process_video(
56
  video_file,
57
- task_type,
58
  landmark_radius,
59
  landmark_color,
60
  connection_color,
61
  connection_thickness,
62
  ):
63
  """
64
- Process video with pose estimation and return output video path.
65
 
66
  Args:
67
  video_file: Uploaded video file
68
- task_type: "hand_pose_estimation" or "body_pose_estimation"
69
  landmark_radius: Radius size for landmarks (int)
70
  landmark_color: Color for landmarks (hex string or tuple)
71
  connection_color: Color for connections (hex string or tuple)
@@ -101,21 +94,12 @@ def process_video(
101
 
102
  print(f"Drawing settings: {drawing_settings}")
103
 
104
- # Process video based on task type
105
- if task_type == "hand_pose_estimation":
106
- process_hand_pose_estimation(
107
- video_file,
108
- str(frames_dir),
109
- drawing_settings
110
- )
111
- elif task_type == "body_pose_estimation":
112
- process_body_pose_estimation(
113
- video_file,
114
- str(frames_dir),
115
- drawing_settings
116
- )
117
- else:
118
- raise ValueError(f"Unknown task type: {task_type}")
119
 
120
  # Create video from processed frames
121
  create_video_from_images(str(frames_dir), str(output_video_path), fps=30)
@@ -130,21 +114,15 @@ def process_video(
130
 
131
 
132
  # Create Gradio interface
133
- with gr.Blocks(title="Pose Estimation") as demo:
134
- gr.Markdown("# Pose Estimation")
135
- gr.Markdown("Upload a video and process it with hand or body pose estimation")
136
 
137
  with gr.Row():
138
  with gr.Column():
139
  # Input controls
140
  gr.Markdown("## Input Settings")
141
 
142
- task_dropdown = gr.Radio(
143
- choices=["hand_pose_estimation", "body_pose_estimation"],
144
- value="hand_pose_estimation",
145
- label="Select Pose Estimation Task"
146
- )
147
-
148
  landmark_radius = gr.Number(
149
  value=20,
150
  label="Landmark Radius",
@@ -154,14 +132,14 @@ with gr.Blocks(title="Pose Estimation") as demo:
154
  precision=0
155
  )
156
 
157
- landmark_color = gr.ColorPicker(
158
- value="#B37CF7", # Default: (179, 124, 247) in RGB
159
- label="Landmark Color (BGR)"
160
  )
161
 
162
- connection_color = gr.ColorPicker(
163
- value="#E1E1E1", # Default: (225, 225, 225) in RGB
164
- label="Connection Color (BGR)"
165
  )
166
 
167
  connection_thickness = gr.Number(
@@ -207,14 +185,13 @@ with gr.Blocks(title="Pose Estimation") as demo:
207
  )
208
 
209
  # Handle processing
210
- def process_and_update(video, task, radius, land_color, conn_color, conn_thickness):
211
  try:
212
  # Update status
213
  gr.Info("Processing video... This may take a few minutes.")
214
 
215
  output_path = process_video(
216
  video,
217
- task,
218
  int(radius),
219
  land_color,
220
  conn_color,
@@ -229,7 +206,7 @@ with gr.Blocks(title="Pose Estimation") as demo:
229
 
230
  process_button.click(
231
  fn=process_and_update,
232
- inputs=[video_upload, task_dropdown, landmark_radius, landmark_color, connection_color, connection_thickness],
233
  outputs=[video_output, download_button]
234
  )
235
 
 
6
  import yaml
7
  from src.utils import (
8
  create_video_from_images,
 
9
  process_body_pose_estimation,
10
  )
 
 
 
 
11
 
12
 
13
  def hex_to_bgr(color_input):
 
49
 
50
  def process_video(
51
  video_file,
 
52
  landmark_radius,
53
  landmark_color,
54
  connection_color,
55
  connection_thickness,
56
  ):
57
  """
58
+ Process video with body pose estimation and return output video path.
59
 
60
  Args:
61
  video_file: Uploaded video file
 
62
  landmark_radius: Radius size for landmarks (int)
63
  landmark_color: Color for landmarks (hex string or tuple)
64
  connection_color: Color for connections (hex string or tuple)
 
94
 
95
  print(f"Drawing settings: {drawing_settings}")
96
 
97
+ # Process video with body pose estimation
98
+ process_body_pose_estimation(
99
+ video_file,
100
+ str(frames_dir),
101
+ drawing_settings
102
+ )
 
 
 
 
 
 
 
 
 
103
 
104
  # Create video from processed frames
105
  create_video_from_images(str(frames_dir), str(output_video_path), fps=30)
 
114
 
115
 
116
  # Create Gradio interface
117
+ with gr.Blocks(title="Body Pose Estimation") as demo:
118
+ gr.Markdown("# Body Pose Estimation")
119
+ gr.Markdown("Upload a video and process it with body pose estimation")
120
 
121
  with gr.Row():
122
  with gr.Column():
123
  # Input controls
124
  gr.Markdown("## Input Settings")
125
 
 
 
 
 
 
 
126
  landmark_radius = gr.Number(
127
  value=20,
128
  label="Landmark Radius",
 
132
  precision=0
133
  )
134
 
135
+ landmark_color = gr.Textbox(
136
+ value="#B37CF7",
137
+ label="Landmark Color (hex, e.g. #B37CF7)"
138
  )
139
 
140
+ connection_color = gr.Textbox(
141
+ value="#E1E1E1",
142
+ label="Connection Color (hex, e.g. #E1E1E1)"
143
  )
144
 
145
  connection_thickness = gr.Number(
 
185
  )
186
 
187
  # Handle processing
188
+ def process_and_update(video, radius, land_color, conn_color, conn_thickness):
189
  try:
190
  # Update status
191
  gr.Info("Processing video... This may take a few minutes.")
192
 
193
  output_path = process_video(
194
  video,
 
195
  int(radius),
196
  land_color,
197
  conn_color,
 
206
 
207
  process_button.click(
208
  fn=process_and_update,
209
+ inputs=[video_upload, landmark_radius, landmark_color, connection_color, connection_thickness],
210
  outputs=[video_output, download_button]
211
  )
212