reab5555 commited on
Commit
9f8bcd3
·
verified ·
1 Parent(s): 69dc1f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -105,10 +105,8 @@ def gradio_app():
105
  def process_and_update(video, target):
106
  frames, error = process_video(video, target, progress_bar)
107
  if frames is not None:
108
- frame_slider.maximum = len(frames) - 1
109
- frame_slider.value = 0
110
- return frames, frames[0], error, gr.Slider.update(maximum=len(frames) - 1, value=0)
111
- return None, None, error, gr.Slider.update(maximum=100, value=0)
112
 
113
  def update_frame(frame_index, frames):
114
  if frames and 0 <= frame_index < len(frames):
@@ -117,7 +115,7 @@ def gradio_app():
117
 
118
  video_input.upload(process_and_update,
119
  inputs=[video_input, target_input],
120
- outputs=[processed_frames, output_image, error_output, frame_slider])
121
 
122
  frame_slider.change(update_frame,
123
  inputs=[frame_slider, processed_frames],
@@ -125,12 +123,12 @@ def gradio_app():
125
 
126
  def use_sample_video():
127
  sample_video_path = "Drone Video of African Wildlife Wild Botswan.mp4"
128
- frames, output_image, error, slider_update = process_and_update(sample_video_path, "Elephant")
129
- return frames, output_image, error, slider_update
130
 
131
  use_sample_button.click(use_sample_video,
132
  inputs=None,
133
- outputs=[processed_frames, output_image, error_output, frame_slider])
134
 
135
  return app
136
 
 
105
  def process_and_update(video, target):
106
  frames, error = process_video(video, target, progress_bar)
107
  if frames is not None:
108
+ return frames, frames[0], error, len(frames) - 1, 0
109
+ return None, None, error, 100, 0
 
 
110
 
111
  def update_frame(frame_index, frames):
112
  if frames and 0 <= frame_index < len(frames):
 
115
 
116
  video_input.upload(process_and_update,
117
  inputs=[video_input, target_input],
118
+ outputs=[processed_frames, output_image, error_output, frame_slider.maximum, frame_slider.value])
119
 
120
  frame_slider.change(update_frame,
121
  inputs=[frame_slider, processed_frames],
 
123
 
124
  def use_sample_video():
125
  sample_video_path = "Drone Video of African Wildlife Wild Botswan.mp4"
126
+ frames, output_image, error, slider_max, slider_value = process_and_update(sample_video_path, "Elephant")
127
+ return frames, output_image, error, slider_max, slider_value
128
 
129
  use_sample_button.click(use_sample_video,
130
  inputs=None,
131
+ outputs=[processed_frames, output_image, error_output, frame_slider.maximum, frame_slider.value])
132
 
133
  return app
134