vu0018 commited on
Commit
ce5aa37
·
verified ·
1 Parent(s): 4360892

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -23,7 +23,7 @@ def calculate_angle(a, b, c):
23
  angle = np.arccos(np.clip(cosine_angle, -1.0, 1.0))
24
  return np.degrees(angle)
25
 
26
- def detect_pose_video(video_path, max_duration=20):
27
  try:
28
  if not os.path.exists(video_path):
29
  return None, "Error: Video file does not exist."
@@ -98,18 +98,18 @@ def detect_pose_video(video_path, max_duration=20):
98
  except Exception as e:
99
  return None, f"Runtime Error: {str(e)}"
100
 
101
- # Gradio interface
102
  with gr.Blocks() as demo:
103
- gr.Markdown("## Human Pose Estimation on Video\nUpload a video (max 20 seconds). Submit is enabled only after upload.")
104
 
105
  video_input = gr.Video(label="Upload Video")
106
  status_output = gr.Textbox(label="Status")
107
  video_output = gr.Video(label="Annotated Video")
108
  submit_btn = gr.Button("Submit", interactive=False)
109
 
110
- # Correct: enable button using .update()
111
  def enable_submit(video):
112
- return submit_btn.update(interactive=True) if video else submit_btn.update(interactive=False)
113
 
114
  video_input.change(enable_submit, inputs=[video_input], outputs=[submit_btn])
115
  submit_btn.click(detect_pose_video, inputs=[video_input], outputs=[video_output, status_output])
 
23
  angle = np.arccos(np.clip(cosine_angle, -1.0, 1.0))
24
  return np.degrees(angle)
25
 
26
+ def detect_pose_video(video_path, max_duration=10): # <- 10 seconds limit
27
  try:
28
  if not os.path.exists(video_path):
29
  return None, "Error: Video file does not exist."
 
98
  except Exception as e:
99
  return None, f"Runtime Error: {str(e)}"
100
 
101
+ # Gradio interface with button enable fix
102
  with gr.Blocks() as demo:
103
+ gr.Markdown("## Human Pose Estimation on Video\nUpload a video (max 10 seconds). Submit is enabled only after upload.")
104
 
105
  video_input = gr.Video(label="Upload Video")
106
  status_output = gr.Textbox(label="Status")
107
  video_output = gr.Video(label="Annotated Video")
108
  submit_btn = gr.Button("Submit", interactive=False)
109
 
110
+ # Enable submit button correctly
111
  def enable_submit(video):
112
+ return gr.Button.update(interactive=True) if video else gr.Button.update(interactive=False)
113
 
114
  video_input.change(enable_submit, inputs=[video_input], outputs=[submit_btn])
115
  submit_btn.click(detect_pose_video, inputs=[video_input], outputs=[video_output, status_output])